So this works fine, as you all know
$("#foo").html = "bar";
But how would I do this?
var i = 开发者_StackOverflow"foo";
$(i).html= "bar";
I've tried $("#"+i)
as well, but that doesn't work either.
This does not work.
$("#foo").html = "bar"; //Overwrites the object's html function with a string
This should.
$("#"+i).html("bar"); //Sets the inner HTML of the selected element.
i don't know what are you tring to do
but if you want to insert this value bar
in the id='foo'
you can use
var i = "foo" ;
$('#'+i).html("bar");
精彩评论