This.id In JQuery Won't Fetch The Element Id If It Is A Number Or Contains Numbers
Solution 1:
Note that numeric-only IDs are invalid. See this post for more info.
The short and sweet of it is:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
Solution 2:
Although it is allowed to use periods and colons, I wouldn't recommend it.
If you ever have to do a selection based on the id jQuery will fail because it will think that it's a new class selector or a filter.
Solution 3:
In the generated html add a prefix like:
<div id="prefix_1" class="draggable" style="top:55px; left:55px; border: 2px solid black; display: inline-table; position: relative; background-color: grey; max-width: 500px;">
<div>Im an Image Posted by:Teh_noob Posted on: 9/15/1991</div>
And in the java script, add the same prefix
Solution 4:
You are trying to get the IDs of elements with other child elements who cover them entirely... that's why you don't get any ID.
Instead of this.id, try e.target.id. If you click on the flash movie then, you get id="flash".
Also you were targeting the wrong element.
Post a Comment for "This.id In JQuery Won't Fetch The Element Id If It Is A Number Or Contains Numbers"