使用jQuery,我已经在一个<a>中选择了一个div,并希望使用$(this)来选择下一个div (我猜这使它成为一个叔叔?)。
我想对我的所有内容使用相同的类名,所以我只想使用相对$(this)。
下面是我所追求的行为的一个例子:
<div><a>click</a></div>
<div> SELECT THIS DIV after click a </div> (real code below)
我一直在尝试,如果我不关闭<a>周围的div,它就可以正常工作。.next('div
我正试图理解jquery中find()和最近()之间的区别。下面是我使用jquery的简单代码。*这只是一个虚拟表单。我只想了解他们之间的区别。所以别以为我会用这个简单的表格做什么。*
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
function myFunction(){
var form
我有两个div,它们具有相同的数据属性,如下所示:
$("#devMap div").click(function(){
var data = $(this).attr('data-name');
alert(data); //this is getting the correct data-name value
if($('#accordian .blocks').data('name')===data){
$(this).toggleClass('active
注意:在这里可以找到整个代码:
问题:我无法通过事件检索{此}}值。Console.log()正在打印0。
我的HTML:
<!-- Modal to control who can collaborate on a course-->
<template name="modalAddCollaborators">
<div id="modalAddCollaborators" class="modal fade" role="dialog">
<div class=
我正在尝试创建一个函数,它将文本从特定的列表元素复制到输入表单中。我挣扎的是,我的函数只是复制所有的文本,而不是特定的元素。有人有什么建议吗?如何正确地(动态地)指示列表对象?谢谢!
<!--Copy into Form Field-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!--Input field and list items-->
<input type="te