本文實(shí)例講述了jquery通過(guò)closest選擇器修改上級(jí)元素的方法。分享給大家供大家參考。具體如下:
這段代碼演示了jQuery通過(guò)closest選擇器獲取上一級(jí)的元素,然后修改其text()內(nèi)容。
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title> www.survivalescaperooms.com </title><script type='text/javascript' src='jquery-1.9.1.js'></script><script type='text/javascript'>//<![CDATA[$(window).load(function(){var address = $("#jb51").closest("div");address.text('www.survivalescaperooms.com')});//]]></script></head><body><div id="website"><div id="jb51"></div></div></body></html>更多關(guān)于jquery選擇器相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《jquery選擇器用法總結(jié)》
希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注