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

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -