我想知道是否有办法在 .text()
函数内使用对对象本身的引用 $(this)
一种使其值(value)加1的方法。
伪代码示例:
jQuery("div").text(+$(this).text() + 1);
预先感谢您的帮助。 干杯。
最佳答案
最简单的方法是使用处理函数:
jQuery("div").text(function(i, str) {
// 'this' can be used here as well
return +str + 1;
});
关于javascript - 找不到使 .text() 使用其自身值的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20803035/