I have following code snippet:
$(document).ready( function() {
$("#input1").contextMenu({
menu: 'myMenu'
},
function(action, el, pos) {
alert("clicked");
});
The above code is not working coz input1 is a variable that contains the elementId generating at run time.
Suppose input1 is generating as follows:
var input1 = “input”+j;
where j is a variable having value 0
Please guide how can i use variable input1 as a elementId in jQuery selector.
Thanks.
Use string concatenation to form the selector:
Obviously this assumes that the variable
input1exists and has the desired value when that code is executed.