开发者

Change Text of elements by clicking it. jQuery

I have button and when I click it a html page loads to div with id=myDiv. Then I want to change the text of certain tags when they are clicked. Like if i click the text that is in h2 tag the text of the h2 tag change to some sting.

"My Page" would be "Text Removed" after i clicked "My Page".

Been trying to use text() to change the text, but now always when i click on the area of myDiv the whole html page disappear and my div have only the string "Text Removed"

How can i access every tag开发者_C百科 in the div so i can click on single text inside of

and change it to "text removed"?


$('*', '#myDiv').live('click', function() {
    $(this).text('Text removed');
});

should do it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜