如果特定类与当前元素匹配,我有以下代码来选择元素并动态添加
<script type="text/javascript">
$(document).ready(function(){
$('a#extra').click(function(event){
// alert($(this).attr('class'));
if($(this).attr('class') == 'extra'){
event.preventDefault();
$(this).append('<div style="float:left;color:red;margin-left:10px;font:20px;margin: 3px 0 0 10px;">Please Login/Register to view Details</div>').slideToggle(5000);
window.location.href='http://weddingsinwinnipeg.ca/signin/';
}
});
});
</script>
<a href="" class="extra extra_120" id="extra"></a>
<a href="" class="extra extra_145" id="extra"></a>
<a href="" class="extra extra_156" id="extra"></a>
我想添加到我点击的锚元素,但上面的代码不起作用,请帮忙