jquery基本操作

來源:互聯網
上載者:User

標籤:cte   height   元素   text   seo   ted   選中   列表   ons   

1.css樣式操作

1)擷取樣式 $(‘div‘).css(‘width‘));

2)擷取某元素的多個樣式 $(‘div‘).css([‘width‘,‘height‘])

3)修改樣式 $(‘div‘).css(‘width‘,‘200px‘);

      $(‘div‘).css(‘color‘,function (index,value){

        console.log(index,value);return ‘pink‘;
        });

4)批量修改樣式 $(‘div‘).css({‘color‘:‘pink‘,‘width‘:‘200px‘});

2.value操作

1)擷取文字框內容 $(‘input‘).val();

2).擷取複選框的選中的內容:console.log($(‘.box:checked‘));

3)設定文字框的值 $(‘.text‘).val("國家");

4)設定複選框的選中 $(‘.box‘).val([1,3]);

5)擷取單選框的value值 $(‘.s:checked‘).val();

6)設定單選框的value值 $(‘.s‘).val([‘c‘]);

7)擷取下拉式清單的value值 單選 $(‘option:selected‘).val();

            多選 $(‘select‘).val()

8)設定下拉式清單的value值 $(‘select‘).val([‘E‘,‘A‘]);

3.簡單事件操作

1)mouseover

 

2)mouseout

3)mouseenter()和mouseleave()在穿過子項目的時候不會觸發

 

不論滑鼠指標穿過被選元素或其子項目,都會觸發 mouseover 事件。
// 只有在滑鼠指標穿過被選元素時,才會觸發 mouseenter 事件。

 

 

  

 

jquery基本操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.