开发者

Call load using a div id that has been passed into a function, div id is a parameter

开发者 https://www.devze.com 2022-12-27 04:41 出处:网络
I am dynamically creating divs within a jquery accordion that are loaded with data as when the user clicks on the accordion title. I have this all working except that when I pass the div id into the l

I am dynamically creating divs within a jquery accordion that are loaded with data as when the user clicks on the accordion title. I have this all working except that when I pass the div id into the load 开发者_StackOverflow中文版details method, the call to .load() does not work. What can I do to fix this? It seems like a simple javascript string eval would work but I can not find what I am looking for.

Code: Here is the basic function:

function loadDetails(div_id) {
   var load_string = "ajax/get_details.aspx";
   $(div_id).load(load_string);
 }

This function is called correctly on the click event and the div_id is passed in correctly but the load function is not working. If I use code like this it work correctly:

$('#test').load(load_string);


$("#" + div_id).load(load_string);

I'm assuming the div_id being passed in is missing the pound?


maby: $('#' + div_id).load(load_string);

http://api.jquery.com/id-selector/

0

精彩评论

暂无评论...
验证码 换一张
取 消