3.26 Notes

var $li = $('ul li:eq(1)');
  var li_txt = $li.text();
  alert(li_txt);
find element node
var $para = $('p');
var p_text = $ para.attr('title');
alert(p_text); .find
attribute node
 var $li_1 = $('<li>1</li>');
var $li_2 = $('<li>2</li >');
$('ul').append($li_1);
$('ul').append($li_2);
Create element node
var $li_1 = $('<li title="banana">banana< /li>');
var $li_2 = $('<li title="Sydney">Sydney</li>');
$('ul').append($li_1);
$('ul').append ($li_2);
Create attribute node
$(function(){
      //Get style
      $("input:eq(0)").click(function(){
alert( $("p").attr("class") );
  }) ;
      //set style
  $("input:eq(1)").click(function(){
$("p").attr("class","high");
  });
      //append style
  $("input:eq( 2)").click(function(){
$("p").addClass("another");
  });    
  //Remove all styles show
() method and hide() method
The display style is changed to ' none '.
The show() method sets the element's display style to the previous display state.
The parameters of the show() method and hide() method can specify the millisecond value to slowly hide and show.
$('p').toggle(function(){
$(this).hide(2000);
},function(){
$(this).show(2000);
}) 
  $("input:eq(3) ").click(function(){
$("p").removeClass();
  });  
   //Remove the specified style
  $("input:

  });   
  //Repeat toggle style
  $("input:eq(5)").click(function(){
$("p").toggleClass("another");
  });  
  //Determine whether the element contains a certain style
  $("input:eq(6)").click(function(){
alert( $("p").hasClass("another") )
alert( $("p").is(".another" ) )
  });  
  });

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325641512&siteId=291194637