daveVk

msg:4557280 | 12:47 am on Mar 22, 2013 (gmt 0) |
<div id="ID1" onclick="clickable(this)">Div 1</div> ... function clickable(el) { alert(el.id); // gives ID1 } Note that when onclick is set his way (as opposed to within javascript) the value must be a statement onclick="clickable" BAD onclick="clickable()" OK onclick="clickable(this)" OK onclick="alert(this.id)" OK
|
sssweb

msg:4557382 | 1:19 pm on Mar 22, 2013 (gmt 0) |
Great, thanks. Glad I asked -- never would have gotten that on my own. Just to follow up, the only way I could get el.id to work in a jQuery command was to use: $("#" + el.id).show(); Is that the only/best way to code it? Seems a little complex for a simple var.
|
daveVk

msg:4557613 | 11:42 pm on Mar 22, 2013 (gmt 0) |
For that you do not need to get the id or even give it an id in the first place. $(el).show();
|
sssweb

msg:4557802 | 5:06 pm on Mar 23, 2013 (gmt 0) |
Ouch -- that was easy. My javascript ignorance is showing. Some day I'll be able to afford a professional programmer to do my website. Until then, you guys are life savers. Many thanks, DaveVk.
|
|