$('#tree')jstree()get_checked(); //获取所有选中的节点ID
$('#tree')jstree()get_checked(true); //获取所有选中的节点对象
通常元素的ID获取使用getElementById()方法,实例如下:
元素值设定为input:
<input name="input_name" id="input_id" class="password"></input>
在JS中获取ID值也就是“input_id”这个值:
<script type="text/javascript" language="javascript">
var item = documentgetElementById("input_id");
</script>
如此,所有为input_id的ID的input对象都在item中了。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,height=device-height, initial-scale=10, maximum-scale=10, user-scalable=0, shrink-to-fit=no">
<title>Title</title>
</head>
<body>
<div id="container">
<div id="id_1">textContent_1</div>
<div id="id_2">textContent_2</div>
<div id="id_3">textContent_3</div>
<div id="id_4">textContent_4</div>
<div id="id_5">textContent_5</div>
<div id="id_6">textContent_6</div>
<div id="id_7">textContent_7</div>
<div id="id_8">textContent_8</div>
<div id="id_9">textContent_9</div>
<div id="id_10">textContent_10</div>
<div id="no_1">textContent_no_event_call</div>
<div id="no_2">textContent_no_event_call</div>
<div id="no_3">textContent_no_event_call</div>
<div id="no_4">textContent_no_event_call</div>
<div id="no_5">textContent_no_event_call</div>
</div>
<script type="text/javascript">
//采用代理方式处理
var divs = documentquerySelectorAll("div[id^='id_']");
var ids = Arrayprototypeslicecall(divs)map(function (div) {
return divid;
});
documentquerySelector('#container')addEventListener('click', function (e) {
if (idsindexOf(etargetid) > -1) {
alert(etargettextContent);
}
}, false);
</script>
</body>
</html>
/
@see 鼠标点击拖拽的效果(页面可以同时拖动多个框)
@param boxId 整个对象(框)的id(一般为div或table)
@param event 内置对象(必须传入)
/
function mousePlead1(event, boxId) {
var o = getO(boxId);
var isIE = documentall true : false;
var e = event;
var x = eoffsetX || elayerX;
var y = eoffsetY || elayerY;
documentonmousemove = function(e) {
ostylefilter = 'Alpha(opacity=70)';
ostyleopacity = '07';
if (isIE) {
osetCapture();
} else {
windowcaptureEvents(EventMOUSEMOVE);
}
var e = windowevent || e;
if (eclientX - x >= 0 && eclientY - y >= 0 && eclientX - x <= getWinSize()[0] - getO(boxId)offsetWidth
&& eclientY - y <= getWinSize()[1] - getO(boxId)offsetHeight) {
ostyleleft = (eclientX - x) + "px";
ostyletop = (eclientY - y) + "px";
}
};
documentonmouseup = function(e) {
documentonmousemove = function() {
};
if (isIE) {
oreleaseCapture();
} else {
windowreleaseEvents(oMOUSEMOVE);
}
ostylefilter = "";
ostyleopacity = "";
};
}
/
@see 获得对象
@param id 对象的id(表单元素和其他标签都可以)
@return Object
/
function getO(id) {
return documentgetElementById(id);
}
/
@see 获得当前窗体的大小(width,height)
@return Array
/
function getWinSize() {
var width = parseInt(documentdocumentElementclientWidth);
var height = parseInt(documentdocumentElementclientHeight);
return new Array(width, height);
}
你的id命名有问题,不能全是数字或者数字开头
如果你只是想用li存数据的话,你自己定义一个属性比如mydata
然后你可以通过getAttribute('mydata')来读取这个属性的值
以上就是关于jstree 如何获得选中节点的值全部的内容,包括:jstree 如何获得选中节点的值、javascript中如何获取元素的ID、js/jquary 获取当前元素id等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)