i need to get the array id and put this id number in the var pointerid = (id number from array);
i am using this code to store the cliked id from element:
jQuery('a').click(function(){
var clickedId= $(this).attr("id");
now i want to search if 'element' : 'Equals to clickedId', if yes, get array id.
for example:
clickedId= test
wp_button_pointer_array[1] = {
'element' : 'test'
so here 'element' : 'test' = clickedId (test) then give me the array id. array id here is 1
var wp_button_pointer_array = new Array();
wp_button_pointer_array[1] = {
'element' : 'wp-button-pointer',
'options' : {
'content': 'The HTML content to show inside the pointer',
'position': {'edge': 'top', 'align': 'center'}
}
};
wp_button_pointer_array[2] = {
'element' : 'some-element-id',
'options' : {
'content': 'The HTML content to show inside the pointer',
'position': {'edge': 'top', 'align': 'center'}
}
};
... = [];, not... = new Array();, and in this case should just bewp_button_pointer_array = [ {...}, {...} ];since JavaScript's basic syntax allows for arrays with content. First making an empty array and then filling it is usually discouraged unless the filling happens in dynamic code.new Array()can be used, and treated as a normal array. The difference is that it's using Constructor notation VS literal notation, soArray Objectother than anArray.new Array()is discouraged (not "bad", just discouraged - unlike new Array(size), which is usually bad unless you need to create a pre-length-assigned array that you then immediately collapse)