[問題] jquery 選取上層li文字問題

作者: valentseng (ValenTseng)   2015-08-06 18:13:11
初學jquery,想建立一個目錄樹,點目錄後可以取得上層的<li>元素內容,
用來取得路徑,再用ajax傳給其他頁面處理。
$("li").bind("click",function(event){
if (event.target == this) {
$.ajax({
url: "getpath.php",
type: 'GET',
data: {
path: $(this). <
作者: oToToT (屁孩)   2015-08-06 18:28:00
$(this).parent()
作者: valentseng (ValenTseng)   2015-08-07 10:52:00
$(this).parent() 應會抓到ul的空值。
作者: fgh81113 (阿景)   2015-08-07 10:58:00
抓到空值不要放到path裡就好 然後繼續往上層抓
作者: Kenqr (function(){})()   2015-08-07 16:21:00
$(this).parent().closest('li')
作者: oToToT (屁孩)   2015-08-07 18:02:00
for往上爬上去
作者: dlikeayu (太陽拳vs野球拳)   2015-08-11 05:30:00
closest

Links booklink

Contact Us: admin [ a t ] ucptt.com