jquery-selectors

jquery fadeout current div, find next div and fade in or find last and fade in

折月煮酒 提交于 2021-02-04 21:40:41
问题 I have div class called .stage which is a stage of a questionnaire <div class="stage"> <div class="next">Next</div> </div> <div class="stage"> <div class="back">Back</div> <div class="next">Next</div> </div> <div class="stage"> <div class="back">Back</div> <div class="next">Next</div> </div> <div class="stage"> <div class="back">Back</div> </div> I am trying to write some compact jQuery that if you select next it closes the current stage and opens the next stage or if you click back it closes

How can one select specific sibling of a context node using jQuery?

不问归期 提交于 2021-02-04 18:10:48
问题 How can one select a specific sibling of a context node using jQuery? Specifically, given context node myContextNode select the sibling span with class myClass . document.evaluate("../span[@class='myClass']", myContextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null). singleNodeValue; 回答1: You can use .siblings() with a selector, like this: $(myContextNode).siblings("span.myClass") 来源: https://stackoverflow.com/questions/2569699/how-can-one-select-specific-sibling-of-a-context-node-using

Passing variable to :eq jquery selector in a while loop

坚强是说给别人听的谎言 提交于 2021-01-28 19:42:47
问题 I'm trying to assign jquery hover functions to all the elements inside <ul> list with this code: var element = 0; var length = $(".artist-list-link").length; while (element<length) { $(".artist-list-link:eq("+element+")").hover(function() { $(".artist-back:eq("+element+")").css('display','block'); $(".artist-hover:eq("+element+")").fadeIn(100); }, function() { $(".artist-back:eq("+element+")").css('display','none'); $(".artist-hover:eq("+element+")").fadeOut(100); }); element++; }; The markup

mousedown event on options in select with jquery .on

Deadly 提交于 2021-01-28 11:47:52
问题 I was reading the documentation of the .on event handler of jQuery and I started playing around with it. I have a simple <select> element with the multiple attribute set to true. However, I want the user to be able to select multiple items without having to press the ctrl or shift key(s) According to the .on documentation, if you specify a selector it will automatically add those event handlers to any new items added inside that container that match the selector specified. So in my case, I

JQuery issue with firefox: $('#element_id').html() not working

本秂侑毒 提交于 2021-01-28 05:00:35
问题 <div id="element_id">hellow world</div> var value = $('#element_id').html() returns the "hello world" sometimes, but not always. val() always works, but not html() This only happens in firefox (always works in Chrome). Any ideas? EDIT Still haven't figured out the problem yet, but I will post the conclusion once I have found it! Thanks for the responses. 回答1: I think this previous question might help you. P.S. When you say it is sometime working and sometime not working, are there some

What is the use of (“*”) in jquery

一曲冷凌霜 提交于 2021-01-27 13:41:23
问题 I am reading jQuery, i don't know why use ("*") please explain it's helpful <script> $(document).ready(function(){ $("button").click(function(){ $("*").hide(); }); }); </script> 回答1: * is a selector in jquery which select everything without any condition including html, head and body. Here is an example explaining its usage. $(document).ready(function(){ $("button").click(function(){ $("*").hide(); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script

Jquery - Get Text Between 2 Div Tags

有些话、适合烂在心里 提交于 2021-01-27 13:25:37
问题 UPDATED : Please look code below: <div class='parent'> <div class='first'>whatever content</div> <div class='child1'></div> Paragraph 1 <br> Paragraph 2 <div class='child2'></div> <div class='child3'>whatever</div> i don't wanna this text <div class='last'>whatever</div> </div> How can I get text " Paragraph 1 Paragraph 2 " without text " I don't wanna this text " from that code? Thank you. NOTED : I CAN'T EDIT/CHANGE HTML CODE . 回答1: 1 - How to get only a content without tags: HTML: <div

Jquery - Get Text Between 2 Div Tags

回眸只為那壹抹淺笑 提交于 2021-01-27 13:20:38
问题 UPDATED : Please look code below: <div class='parent'> <div class='first'>whatever content</div> <div class='child1'></div> Paragraph 1 <br> Paragraph 2 <div class='child2'></div> <div class='child3'>whatever</div> i don't wanna this text <div class='last'>whatever</div> </div> How can I get text " Paragraph 1 Paragraph 2 " without text " I don't wanna this text " from that code? Thank you. NOTED : I CAN'T EDIT/CHANGE HTML CODE . 回答1: 1 - How to get only a content without tags: HTML: <div

How to append an extra 'Zero' after decimal in Javascript

谁说我不能喝 提交于 2021-01-27 04:28:22
问题 Hye, Iam new to javascript working with one textbox validation for decimal numbers . Example format should be 66,00 .but if user type 66,0 and dont type two zero after comma then after leaving text box it should automatically append to it .so that it would be correct format of it . How can i get this .How can i append ?? here is my code snippet. function check2(sender){ var error = false; var regex = '^[0-9][0-9],[0-9][0-9]$'; var v = $(sender).val(); var index = v.indexOf(','); var

How to select an element which doesn't have a specific class name, using jQuery?

让人想犯罪 __ 提交于 2021-01-27 02:17:53
问题 How could a Commando, like myself, select an element witch does not have a class named "active", using the infamous and powerful jQuery Sizzle CSS and everything else - Selector? I've tried with: $('a[class!="active"]').etc(); But it gives no adequate results. 回答1: $('a:not(.active)') should work yours works as well. just tested: http://jsfiddle.net/UP6a7/ 来源: https://stackoverflow.com/questions/7399956/how-to-select-an-element-which-doesnt-have-a-specific-class-name-using-jquery