JavaScript. 2 issues
Date: 08/24/10
(Javascript Community) Keywords: html, java
Hello.
I'm a newbie in JavaScript (and jQuery, too).
I've got some little troubles with it.
First. I'd love to know how to obtain an ID of clicked element inside click event handler.
According to the book "Learning jQuery" by Jonathan Chaffer and Karl Swedberg, I gotta use "this.id" construction.
Perhaps this book is little outdated because it doesn't work under jQuery 1.4.2.
Calling "alert(this.id);" in the event handler is resulting in "undefined" message.
Second. I'm trying to figure out how to attach a click event handler to the element created dynamically by script.
The following line of code is resulting in new unclickable picture on my page:
myDiv.innerHTML = myDiv.innerHTML + '';
This problem is not being solved by using the code like this: $('.Pics').Click('ClickIMG').
I think these issues are quite common and can be easily solved.
So you probably can help me.
Thank you.
Source: https://javascript.livejournal.com/171768.html