passing variables to an attribute in jquery -


how can pass variable in jquery this:

   var info = $(this).attr("id");    var course2 = $('div[name=info]').html;    $("#courseinfo").html(course2); 

i having difficulty second line..

var info = $(this).attr("id"); var course2 = $('div[name="' + info + '"]').html(); $("#courseinfo").html(course2); 
  • put info variable inside quotes.
  • get html part of div using html() method without arguments.
  • set html courseinfo passing html string html(course2).
  • for more details, please read .html() api documentation.

Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -