我希望通过其属性找到<a>
标记,通过javascript找到属性值...但它不起作用...
<a class="btn-u btn-u-split-red tooltips CancelOredr" data-guid="1351e01d-8e89-4adc-b3f2-10c0c8ccaa5b" href="/User/UserProfile/Index/1351e01d-8e89-4adc-b3f2-10c0c8ccaa5b" title="" data-placement="bottom" "></a>
<script>
$(document).on('click', '.CancelOredr', function (e) {
var OrderID = "1351e01d-8e89-4adc-b3f2-10c0c8ccaa5b";
var trEl = $('[data_guid=' + OrderID + ']');
trEl.css("background", "#F5F5AF");
trEl.delay(1000).fadeOut(1000);
});
</script>
答案 0 :(得分:1)
你的JS中有一个下划线,它是你html中的连字符:
var trEl = $('[data_guid='+OrderID +']');
应该是:
var trEl = $('[data-guid='+OrderID +']');