当前位置: 代码迷 >> 综合 >> jQuery通过id属性来获取元素,通过.addClass()方法来添加class.
  详细解决方案

jQuery通过id属性来获取元素,通过.addClass()方法来添加class.

热度:68   发布时间:2023-11-17 15:06:17.0

Target Elements by ID Using jQuery


你还可以根据id属性来获取元素

首先用$("#target3")来选择id为target3button元素。

注意,就像CSS一样,在id的名字前加上 #

然后使用jQuery的.addClass()方法来添加 animatedfadeOutclass.

例如:下面的代码就是给id为target6button元素添加fade out效果的:

$("#target6").addClass("animated fadeOut")




  相关解决方案