jquery-selectors

What does `a > b` mean?

孤街浪徒 提交于 2020-01-21 20:07:30
问题 I'm reading a tutorial about creating a shoutbox with jquery, php and ajax. In the jquery code, it creates a variable like this var messageList = $(".content > ul"); There is a "content" class in the html, and it has an unordered list in it. But I don't understand the syntax .content > ul in the creation of the variable. Can you explain? HTML <div class="content"> <h1>Latest Messages</h1> <div id="loading"><img src="css/images/loading.gif" alt="Loading..." /></div> <ul> <ul> </div> 回答1: It

jQuery - 'this' selector doesn't work inside callback function [duplicate]

江枫思渺然 提交于 2020-01-21 07:14:41
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: $(this) doesn't work in a function I'm writing post removing code in jQuery, The removing itself is made via post-request to backeds, after server returns 200, I want to delete this post on client-side. $('.delete-post').click(function() { $.post($(this).attr('href'), {}, function(data) { $(this).closest('.post').remove(); }); return false; }); However, I've noticed that inside function(data) {...) selector

How to check if a radio button in each group is checked in jQuery?

老子叫甜甜 提交于 2020-01-19 05:39:40
问题 Multiple groups or radio buttons <h1>Question 1</h1> <input type="radio" name="radio1" value="false" /> <input type="radio" name="radio1" value="true" /> <h1>Question 2</h1> <input type="radio" name="radio2" value="false" /> <input type="radio" name="radio2" value="true" /> How can I check in jQuery that a radio button in each group is checked? Thank you. 回答1: Here is how I would do it: var all_answered = true; $("input:radio").each(function(){ var name = $(this).attr("name"); if($("input

Sibling Hover Opacity

半腔热情 提交于 2020-01-17 12:42:06
问题 As per this question here, I'm trying to have one navigational element in a set of two disappear when the other is hovered. Because one necessarily precedes the other, this is apparently not possible currently with CSS, so it needs to be done with jQuery. I have the following line of jQuery at the top of my page (inside a script element), but it doesn't appear to be working: $(document).ready(function(){ $('.sb-bignav:hover').siblings().css({ 'opacity': '0', '-webkit-opacity': '0', '-moz

Is there any way to use a JS variable as input instead of jquery selector “#id”?

孤街醉人 提交于 2020-01-17 09:20:03
问题 I want to know that, can we able to give a variable instead of #anyId inside a selector. Actually i am trying this code, <html> <head> <script src="http://code.jquery.com/jquery-latest.min.js"></script> </head> <body> <div id="aDiv123"> <p id="abcd1234" class="abcd123">Click me!</p> </div> <script> $("p").live("click", function() { $(this).after("<p id='abcd123' class='abcd2323'>Another paragraph!</p>"); var number = this.id.match(/^abcd(\d+)$/)[1]; var iD = this.id; alert(number); alert(iD);

<select> dropdown menu to target files that javascript opens

徘徊边缘 提交于 2020-01-17 09:00:50
问题 so I'm parsing CSV files into JSON then editing them so I can get arrays which jquery will use to make a graph. I'm trying to make a dropdown menu so the user can select a CSV file from which the graph will be made. So far I've worked with local files so I used {}. I am new to jquery and a beginner in html so please explain what's going on in the solutions. edit: the files directory is "CSV/Sheet1.csv", Sheet2.csv... One way to do this is to write a function which opens a specific file when

Changing text after an input field

柔情痞子 提交于 2020-01-17 05:42:09
问题 How do I change the "2 Year Subscription" to "2 year:" without losing the input field <div class="radioOption subscription1Col3"> <input class="buyNow" type="radio" name="product2" value="6_0" checked="">2 Year Subscription</div> 回答1: This is relatively simple, and I'd suggest the following (though currently untested): var input = $('.radioOption.subscription1Col3 input'), text = input[0].nextSibling.nodeValue, newText = text.replace(/ subscription/i,': '); input[0].nextSibling.nodeValue =

jquery jump to next element

末鹿安然 提交于 2020-01-17 03:53:07
问题 I'm trying to use the jquery next function to click a link to navigate to the next element in an unordered list. What I have is below, but I get a 404 saying it couldn't find [object Object] $('.next').click(function (event) { window.location = $('li').next(); }); and <div id="nextButton"><a href="#" class="next" id="next">></a></div> 回答1: If you posted your code exactly as is, there are a lot of syntax errors. A fixed up version is below: $('.next').click(function (event) { // missing $

JQuery selector to ignore an element?

瘦欲@ 提交于 2020-01-16 20:07:40
问题 I am extracting article page content. One selector, "entry": $('div.content__article-body').html().trim() gets the main article body. This mostly comprises text paragraphs with their <p> and header tags, which is just what I want. However, it also gets an element I don't want, which is <aside> . How can I ensure <aside> is NOT included in the resulting text? I have read threads on here about "not". I have tried things like ... $('div.content__article-body').not('aside').html().trim() $('div

JQuery selector to ignore an element?

孤人 提交于 2020-01-16 20:06:10
问题 I am extracting article page content. One selector, "entry": $('div.content__article-body').html().trim() gets the main article body. This mostly comprises text paragraphs with their <p> and header tags, which is just what I want. However, it also gets an element I don't want, which is <aside> . How can I ensure <aside> is NOT included in the resulting text? I have read threads on here about "not". I have tried things like ... $('div.content__article-body').not('aside').html().trim() $('div