jquery-selectors

nth-child selecting wrong element

寵の児 提交于 2019-12-19 10:57:52
问题 For this particular site, when I utilize nth-child via CSS or jQuery, the 'nth-child' selector is capturing the wrong element. I'm getting one child before the selector that I'm calling: .home article:nth-child(3) {} //captures 2nd child This seems to be capturing the second child instead. If I attempt: .home article:nth-child(1) {} //captures nothing This captures no elements. In jQuery, it shows up as an empty array. Here's the dev site that I'm working on. Thank you. http://heilbrice

jQuery - get next element with same name as id of selected input

半世苍凉 提交于 2019-12-19 10:12:08
问题 First off, I'd like to apologize for the horrid title there, but it was the best way I could think of summing up my issue. Currently, I use a jQuery script that checks, on blur on an input:text , that the text value of the input is greater than a certain amount. If not, the input is highlighted red - but what I'd like to happen next, is to have a <p> in an adjacent column to have it's text changed. My HTML looks like this: <tr> <td width="15%"><label for="example">Hello world</label></td> <td

jQuery $(“img[src=the_image_souce]”).attr('src','new_src'); does not work

☆樱花仙子☆ 提交于 2019-12-19 09:43:12
问题 My code does not work I don't know why the_image_source and new_src are just place holders I have put real values in them I have also tried $("img[src=the_image_souce]")[0].attr('src','new_src'); but it does not work either, please help 回答1: You must be aware by accessing the [0] element in the jQuery Object this will return the DOM element. You cannot use the jQuery attr() method directly on a DOM element. It must be run on a jQuery Object Essentially, if you will have more than one element

Select elements with class except one with specific id

狂风中的少年 提交于 2019-12-19 09:18:09
问题 $('.ui-widget-content').css('border','none'); $('#helpDialog .ui-widget-content').addClass('HelpDialogBorder'); I am doing like this to remove border. But, there is an element where I want to keep border. Is there any way in first line itself to select all elements with class "ui-widget-content" but except one with id "helpDialog"? 回答1: Sure, use :not(): $('.ui-widget-content:not(#helpDialog)').css('border', 0); 回答2: Try this (also see my jsfiddle): $('.ui-widget-content').not('#helpDialog')

jQuery “visible” doesn't work in all browsers, but in Firefox

ε祈祈猫儿з 提交于 2019-12-19 09:14:10
问题 I've made a very simple fiddle here, and you can check it out in different browsers. It only works in Firefox. In other words, seems that $('#select-tag-id option:visible') doesn't work in other browsers. What's wrong? Is it a jQuery bug? The code is: <select id='items'> <option value='1' style='display: none;'>One</option> <option value='1' style='display: block;'>Two</option> <option value='1' style='display: block;'>Three</option> <option value='1' style='display: none;'>Four</option> <

How can I handle XML namespaces in CSS Selectors or in jQuery?

时光总嘲笑我的痴心妄想 提交于 2019-12-19 07:53:37
问题 I use jQuery to parse an RSS feed. I can successfully get the RSS feed using AJAX: $.get("podcast.xml", function (data) { xml = $(data); }, "xml"); Now I can get the title of the podcast by using xml.find("channel > title").text() . How can I select the <itunes:image> tag in my RSS feed? The command xml.find("channel > itunes:image") does not work, because : separates in CSS the tag name and the pseudo class. I also tried xml.find("channel > image") but it does not work. How can I handle XML

jQuery colon selectors

落花浮王杯 提交于 2019-12-19 07:52:46
问题 In jQuery there are a few colon selectors like :prev, :next, :last My question is: Are they truly part of jQuery, because they are actually used on DOM elements? We seem to have equivalent methods as well in jQuery prev() , next() , last() . What is the purpose of having 2 different ways? Any basic examples would be really great. 回答1: jQuery does not have :prev or :next selectors, I have no idea where you came across them. There is a :last selector, though, as well as :first , provided by the

compare jquery selectors performance

扶醉桌前 提交于 2019-12-19 07:51:08
问题 Looking at improving the performance of my jquery selectors. so any tips or articles as the best per formant jquery selectors? For example selecting the a div's id. Anywhere online I can provide html and compare the different selectors I can use to select the required element. 回答1: You can compare selector performance here: http://jsperf.com/ Just setup your HTML, include jQuery and place each selector you want to compare as a test case. Many of the rules here still apply, however the game

Selector for element inside a frame (with same origin)

我是研究僧i 提交于 2019-12-19 06:32:40
问题 I have a webpage with the following structure: <html> <head>...</head> <frameset> <frame name="frame1" src="/index.jsp"/> <frame name="frame2" src="/blank.jsp"/> </frameset> </html> index.jsp contains: <html> <head>...</head> <body> ... <div id="test">test is here</div> ... </body> </html> I need a jQuery selector to directly access div#test . So far I've only been able to write it like this: $(frames[0].document.body) ...or this: $("frame[name='frame1']") . But I have a template which

Selector for element inside a frame (with same origin)

社会主义新天地 提交于 2019-12-19 06:32:32
问题 I have a webpage with the following structure: <html> <head>...</head> <frameset> <frame name="frame1" src="/index.jsp"/> <frame name="frame2" src="/blank.jsp"/> </frameset> </html> index.jsp contains: <html> <head>...</head> <body> ... <div id="test">test is here</div> ... </body> </html> I need a jQuery selector to directly access div#test . So far I've only been able to write it like this: $(frames[0].document.body) ...or this: $("frame[name='frame1']") . But I have a template which