Jquery 如何在all中搜索字符串<;span>;标记,然后用另一个字符串替换该字符串
我实际上是在为我的网站制作一个不同的按钮。 到目前为止我使用的代码-Jquery 如何在all中搜索字符串<;span>;标记,然后用另一个字符串替换该字符串,jquery,html,Jquery,Html,我实际上是在为我的网站制作一个不同的按钮。 到目前为止我使用的代码- $(".unlike").click(function(){ var pid = $(this).attr("id"); var email = $("#hidden").val(); var data = "pid="+pid+"&email="+email; $("#flash").show(); $("#flash").fadeIn(500).html('<img src="wamp.g
$(".unlike").click(function(){
var pid = $(this).attr("id");
var email = $("#hidden").val();
var data = "pid="+pid+"&email="+email;
$("#flash").show();
$("#flash").fadeIn(500).html('<img src="wamp.gif" /> Loading...');
$.ajax({
type: "POST",
url: "unlike.php",
data: data,
cache: false,
success: function(html) {
$("#flash").fadeOut(100);
$("#likes"+id).text(html).replaceWith('');
}
});
$(“.inference”)。单击(函数(){
var pid=$(this.attr(“id”);
var email=$(“#隐藏”).val();
var data=“pid=“+pid+”&email=“+email;
$(“#flash”).show();
$(“#flash”).fadeIn(500).html('Loading…');
$.ajax({
类型:“POST”,
url:“不像.php”,
数据:数据,
cache:false,
成功:函数(html){
$(“#闪光”)。淡出(100);
$(“#likes”+id).文本(html).替换为(“”);
}
});
}))
此代码是单击按钮时发生的。
它将数据发送到inference.php文件,在该文件中从likes表中删除人名,我想要的是,它还应该从标记中删除人名
$('span').each(function(){
$(this).text().replace(/find/g,”replace”)
})
$("span:contains('{enter your search string here}')").each(function(){
$(this).html($(this).text().replace( /{enter your search string here}/g, "{enter your new string here}" );
});
此代码与问题有什么关系?同意,请提供更多信息。我已编辑了我的问题。请看这是否有帮助