我需要能够在li单击时获取确定的文本,代码如下:
<div>
<ul>
<li>list item 1</li>
<li>list item 2</li>
<li>
<ul>
<li>list item 3</li>
<li>list item 4</li>
<li>list item 5</li>
</ul>
</li>
<li>list item 6</li>
<li>
<ul>
<li>list item 7</li>
<li>list item 8</li>
<li>list item 9t</li>
</ul>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我需要通过其索引获取" 列表项5 ".
编辑:
基本上,当<li>list item 5</li>点击时我想获得这个particallar文本或值,当点击其他东西时 - 什么都不做.请注意,虽然菜单是分层的,但第5个元素表示第5个元素.仔细检查li要理解的项目的文本.
有没有人知道如何听CLICK或HOVER等鼠标事件,这样当我点击或悬停任何元素时,它会在第二个浏览器中发生相同的事情?抱歉不包括代码.
<script>
// creating a new websocket
var socket = io.connect('http://localhost:8000');
// on message recived we print the new data inside the #container div
socket.on('notification', function (data) {
$("p").click(function () {
alert("Hello");
//or change the color
$(this).css({"color": "red"});
});
var usersList = "<div id='aaa'>";
$.each(data.users, function (index, user) {
usersList += "<p>" + user.users + "</p>";
});
usersList += "</div>";
$('#container').html(usersList);
});
</script>
<p>Click me!</p>
Run Code Online (Sandbox Code Playgroud) 假设我有几个按钮,当它们被点击时它们会触发某个setInterval,但是当我点击不同的按钮时,前一个setInterval没有清除或它说它是未定义的.
例:
$("#button1").click(function () {
var url = "xxx";
var min = "yyy";
getGraphCredentials3(min,url);
var onehour = setInterval(function () {
getGraphCredentials3(min,url);
}, 5000);
clearInterval(twohour);
});
$("#button2").click(function () {
var url = "zzz";
var min = "uuu";
getGraphCredentials3(min,url);
var twohour = setInterval(function () {
getGraphCredentials3(min,url);
}, 5000);
clearInterval(onehour);
});
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
非常感激
我试图停止/清除间隔,但我收到一个错误.
代码如下:
function play(){
function sequencePlayMode() {
var arg1;//some arguments
var arg2;//some arguments
changeBG(arg1,arg2);//here is function that changes the background
}
var time = 5000;
var timer = setInterval(sequencePlayMode, time);//this starts the interval and animation
}
function stop(){
var stopPlay = clearInterval(sequencePlayMode);//here i'm getting error "sequencePlayMode is not defined"
}
$("#startAnimation").click(function(){
play();
});
$("#stopAnimation").click(function(){
stop();
});
Run Code Online (Sandbox Code Playgroud)
请有人帮我这个吗?