Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all
My Code
JavaScript
var dataTable = "<ol>";
$.each(data.response.docs, function (key, value) {
                            dataTable += '<li ><a href="' + value.id + '"  önmousedown=javascript:StoreClickedURL(' + userId + ',"' + encodeURI(userInput) + '","' + value.id + '")>' + value.id + '</a></li>';
                        });
 dataTable += "</ol>";

I am dynamically creating anchors.Here house down event is working fine in all browser except IE.

I searched in Google but not found any appropriate solution for this.

Please help me.

Thanks in advance
Posted
Updated 8-Nov-12 19:23pm
v2
Comments
Sergey Alexandrovich Kryukov 9-Nov-12 2:24am    
You misuse jQuery. Its style is adding event handler when document is ready. Writing JavaScript event handler is HTML elements is totally redundant thing, and error-prone.
--SA

1 solution

You are going in wrong direction — please see my comment to the question.

This is a jQuery pattern of doing things:
JavaScript
$(document).ready(function(){
   someElement = $("#someId"); // assuming some element has id="someId"
   // generate HTML or not, does not matter
   someElement.mousedown(function(event){
       // so something
   });
});


Please see:
http://docs.jquery.com/How_jQuery_Works[^],
http://api.jquery.com/mousedown/[^],
http://api.jquery.com/category/selectors[^],
http://api.jquery.com/category/Events/[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900