我需要jquery来获取最接近的id,一旦图像可见。到目前为止,这是我的查询
(...)
if(isonscreen)
{
//this works, but I need it to find only images inside the content-bubble div tag
// and of course this grabs any image no matter what div the image is inside of
console.log($(this).closest('img').attr('id'));
在单击页面上的特定链接后,代码会追加页面URL。当我运行代码时,它将按预期执行,只将URL追加到与代码匹配的链接中。然而,当我打印到控制台时,我注意到它似乎对页面上的每一个链接都这样做,尽管应该使用if语句来限制它。当我取出if语句时,代码的功能也是一样的。然而,即使它工作,我想使它更有效率,只运行在与参数匹配的链接上。
// Function to change the link by adding the current page
function setSlateLink() {
// get the URL of the current page
var cur
我正试图理解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