onclick如何更改span中的文本 [英] onclick how to change the text within span
本文介绍了onclick如何更改span中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户点击与Home对应的img元素时,我想将span内的Home更改为Click I'agree。以下是我的代码。
I want to change 'Home' that is within 'span' to 'Click I agree' when the user clicks the img element corresponding to 'Home'. The following is my code.
<li>
<a class="" id="" onclick=""><img src="homelogo.jpg" style=" cursor:pointer; width:40px; height:40px;" /> </a>
<span>Home</span>
</li>
推荐答案
从你的makup,做
From your makup, doing
( document )。 on( 点击, img, function (){
(document).on("click", "img", function() {
( span)。text( 点击我同意)
});
("span").text("Click I agree") });
与
$ b相同$ b
which is the same as
这篇关于onclick如何更改span中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文