Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: IE7 Javascript jQuery Browser , +
Hi all
My Code
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 8-Nov-12 19:38pm
Mac123341.1K
Edited 8-Nov-12 20:23pm
v2
Comments
Sergey Alexandrovich Kryukov at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You are going in wrong direction — please see my comment to the question.
 
This is a jQuery pattern of doing things:
$(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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,800
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100