久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      jquery更改img元素的src屬性的方法

      jquery更改img元素的src屬性的方法:首先在html文件中,給button按鈕綁定onclick點擊事件;然后在js標簽內(nèi)創(chuàng)建editsrc函數(shù);接著通過“id(myimg)”獲得img對象;最后使用attr方法設(shè)置src屬性即可。

      jquery更改img元素的src屬性的方法

      本教程操作環(huán)境:windows7系統(tǒng)、jquery1.10.0版本,該方法適用于所有品牌電腦。

      推薦:《jquery視頻教程》

      在jquery中,主要通過attr()方法來設(shè)置img標簽的src屬性,從而實現(xiàn)改變img標簽的src屬性。

      方法:首先需要獲取img元素,然后使用.attr("src","值")來更改img元素的src屬性。

      具體介紹:

      在test.html文件中,給button按鈕綁定onclick點擊事件,當按鈕被點擊時,執(zhí)行editsrc()函數(shù)。

      jquery更改img元素的src屬性的方法

      在js標簽內(nèi),創(chuàng)建editsrc()函數(shù),在函數(shù)內(nèi),使用$符號通過id(myimg)獲得img對象,使用attr()方法設(shè)置src屬性,例如,設(shè)置src圖片路徑為“images/3.jpg”。

      jquery更改img元素的src屬性的方法

      在瀏覽器打開test.html文件,點擊按鈕,查看實現(xiàn)的效果。

      jquery更改img元素的src屬性的方法

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號