jquery-selectors

how to get content of all <li> tags in one page using jquery

瘦欲@ 提交于 2019-12-31 04:11:12
问题 I have an html list something like this: <li id="tag">red</li> <li id="tag">yellow</li> <li id="tag">blue</li> How can I get the content of these li tags using jQuery? For example; $tags = red, yellow, blue 回答1: You can use jQuery.map() Live Demo texts = $('li').map(function(){ return $(this).text(); }).get().join(','); 回答2: var $tags = $("li").map(function(){ return $(this).text(); }).get().join(","); Here, have a fiddle: http://jsfiddle.net/KTted/2/ 回答3: First, you should change your id=

Adding zoom to Fancybox

自古美人都是妖i 提交于 2019-12-30 17:21:08
问题 I'm using Fancybox for my thumbnail gallery. I'd like to use JQZoom ( http://www.mind-projects.it/projects/jqzoom/ )with the fancybox as well. The end result: 1. User clicks on thumbnail 2.fancybox appears with larger image 3. User can mouse over image to zoom in more using JQZoom Right now I have it set up to do this effect. The fancybox works perfectly, but the JQZoom doesn't work at all. I haven't encountered any errors using firebug either. Here's the page : http://waldondigital.com/mix

JQuery: Hide children, show nth child?

纵饮孤独 提交于 2019-12-30 12:23:43
问题 This is really weird and should be simple. I have an array of images within a tags within a div, eg: <div id="images"> <a href="#"><img src="img1.jpg"/></a> <a href="#"><img src="img2.jpg"/></a> <a href="#"><img src="img3.jpg"/></a> </div> I want to hide all of them, but loop through and show the nth one, so I created this image slider style script: var atags = $('#images').children().length; $('#images').children().hide(); $('#images a:first').show(); var i=0 while (i <= atags){ $('#images')

JQuery: Hide children, show nth child?

柔情痞子 提交于 2019-12-30 12:23:13
问题 This is really weird and should be simple. I have an array of images within a tags within a div, eg: <div id="images"> <a href="#"><img src="img1.jpg"/></a> <a href="#"><img src="img2.jpg"/></a> <a href="#"><img src="img3.jpg"/></a> </div> I want to hide all of them, but loop through and show the nth one, so I created this image slider style script: var atags = $('#images').children().length; $('#images').children().hide(); $('#images a:first').show(); var i=0 while (i <= atags){ $('#images')

jQuery selector for select elements with empty value attributes?

纵然是瞬间 提交于 2019-12-30 10:13:21
问题 I'm using the below selector to get all the form inputs that are pre-populated with a value. $('input[value!=""]'); This works great and so I thought I could apply the same logic to my select elements using the following selector, though it seems to be selecting all the select elements in Chrome. $('select[value!=""]'); Below is an example of two types of selects on the form: <select name="phone2_type" id="phone2_type"> <option value="">Select one:</option> <option value="HOME">Home</option>

jQuery selector for select elements with empty value attributes?

你离开我真会死。 提交于 2019-12-30 10:11:36
问题 I'm using the below selector to get all the form inputs that are pre-populated with a value. $('input[value!=""]'); This works great and so I thought I could apply the same logic to my select elements using the following selector, though it seems to be selecting all the select elements in Chrome. $('select[value!=""]'); Below is an example of two types of selects on the form: <select name="phone2_type" id="phone2_type"> <option value="">Select one:</option> <option value="HOME">Home</option>

what does this mean: “jQuery('> li', this)”

删除回忆录丶 提交于 2019-12-30 09:44:13
问题 I'm trying to figure out how this jQuery plugin works: http://codeasily.com/jquery/multi-column-list-with-jquery In the plugin there is this line at the beginning: if(jQuery('> li', this)) { I know what ul > li means: it means select all li whose direct parent is a ul. But what does '> li' mean? I ran: $('> li') but it returns [] even though I have plenty of nested unordered list HTML on the page. 回答1: Don't use it. The docs advise that you shouldn't use at as it will be soon deprecated. From

How to check if a TR contains a TD with a specific CSS class with jquery?

喜你入骨 提交于 2019-12-30 08:13:17
问题 I know you can use .find to find td:contains('text') , but if I have a tr with say, 3 td's, and one of the td's might have class="specialclass someotherclass" (may potentially have other classes in addition to special class), how do I use jquery to check if a TR contains a TD of specialclass ? 回答1: To select any tr that has a td.specialclass : $('tr:has(td.specialclass)') Or if you have a tr (represented by this ) and you simply want to check if it has such a td : if ($(this).find('td

Select tags that starts with “x-” in jQuery

徘徊边缘 提交于 2019-12-30 08:12:42
问题 How can I select nodes that begin with a "x-" tag name, here is an hierarchy DOM tree example: <div> <x-tab> <div></div> <div> <x-map></x-map> </div> </x-tab> </div> <x-footer></x-footer> jQuery does not allow me to query $('x-*') , is there any way that I could achieve this? 回答1: There is no native way to do this, it has worst performance, so, just do it yourself. Example: var results = $("div").find("*").filter(function(){ return /^x\-/i.test(this.nodeName); }); Full example: http:/

Get clicked option in multiple dropdown

十年热恋 提交于 2019-12-29 07:46:12
问题 I have a multi select dropdown eg: <select id="myList" multiple="multiple"> <option value="1">Opt #1</option> <option value="2" selected="selected">Opt #2</option> <option value="3" selected="selected">Opt #3</option> <option value="4">Opt #4</option> </select> If I then selects Opt #4 , how do I then only get Opt #4 and not Opt #2 and Opt #3 ? I know I can get all selected options by this: var selectedOptions = $("#myList option:selected"); However I only want the option I clicked - Opt #4 .