<p>hello how are u</p><p> </p>
<div class="fbphotobox"><img id="img__kw_field_id"
fbphotobox-src=" Uploads/Images/OriginalImages/developer_635647972105434266.jpg;"
src="Uploads/Images/ResizedImages/developer_635647972105434266.jpg" alt="" /></div>
这是我的字符串,我需要从;
.fbphotobox
中删除src
我正在尝试filter()
但是我的代码中没有这个
var text = $("#<%=hdnDescription.ClientID%>").val();
var found = text.filter(".fbphotobox");
答案 0 :(得分:1)
我建议你在服务器端修复它。
但是你可以使用,
$(document).ready(function() {
//Read attribute and replace text
$('#img__kw_field_id').attr('fbphotobox-src', function(){
return $(this).attr('fbphotobox-src').replace(";","");
});
alert($('#img__kw_field_id').attr('fbphotobox-src'));
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img id="img__kw_field_id" fbphotobox-src=" Uploads/Images/OriginalImages/developer_635647972105434266.jpg;" src="Uploads/Images/ResizedImages/developer_635647972105434266.jpg" alt="" />
&#13;
答案 1 :(得分:-1)
尝试这样的事情:
var text = "hello; dafsdf sd sdf sdf sdf dsf!";
var result = text.replace(";", "");
答案 2 :(得分:-1)
尝试使用
var text = $("#<%=hdnDescription.ClientID%>").val();
var found = text.replace(";","");
希望它有所帮助。