jquery-selectors

jQuery: Get all text inputs where no type is defined

蓝咒 提交于 2019-12-25 11:58:57
问题 When i use $("input[type=text]") i absolutely mean all text boxes but it only return inputs that type has been set for them. For example in: <input name="text1" /> <input name="text2' type="text"/> text1 is not included. how to get all text inputs regardless type has been set or not ? 回答1: Selects the ones with type=text, and the ones without type attribute. $("input[type=text],input:not([type])") 回答2: $('input:text') From the official documentation: As of jQuery 1.5.2, :text selects input

Access $(this) DOM element from within jQuery Autocomplete Widget Ajax call

冷暖自知 提交于 2019-12-25 10:16:04
问题 In the code below (Coffeescript), in the AJAX call for the jQuery autocomplete data source, On line 5 of the code, I am passing 2 params - term: and ll: For ll: I'm trying to get $(this) to be the DOM element that .autocomplete was applied to. In this case its $('[type="text"][name*="[location]"]') I need to reference that DOM element specifically with ($this) on line 5. However, I believe 'this' at that scope refers to something else that isn't a DOM element. Can someone please help explain

jquery show options with a certain class, hide others

岁酱吖の 提交于 2019-12-25 09:28:08
问题 I have two select lists. Both are populated using php and mysql. When the user clicks on an organization in the first list, only events for that organization should show in the events list. The organization id is the value of the options in the organization list and the class for the options in the event list. When I choose organization 3, two events (A and B) should show in the event list. Instead, all the event options disappear! Something must be wrong with my selector for the second menu

Why doesn't my div swap by .class work?

与世无争的帅哥 提交于 2019-12-25 08:39:05
问题 Having trouble converting the following code from dealing with IDs to Classes. Basicly what the code does is reveals one Div while hiding another. In the original version it was simple because the div location was absolute. With the classes version I need to reveal the next instance of 'product-specs' based on which DIV the onClick was located. NOTE/EDIT: Their are multiple versions of the same classes on the page. So references to the classes must be specific to the closest instance of the

jQuery Selector: How to select the children of just THIS element

做~自己de王妃 提交于 2019-12-25 06:46:57
问题 So, I have code that looks like this: <span class="comic_menu mid_menu_title"> <ul> <li class="level-0 page_item page-item-264"><a href="http://www.domain.com.php5-15.dfw1-1.websitetestlink.com/wordpress/?page_id=264" title="Ca$h Rulez">Ca$h Rulez</a> <ul class='children'> <li class="level-1 page_item page-item-266"><a href="http://www.domain.com.php5-15.dfw1-1.websitetestlink.com/wordpress/?page_id=266" title="1994">1994</a></li> <li class="level-1 page_item page-item-268"><a href="http:/

Loop through JSON objects that only start with a certain pattern

五迷三道 提交于 2019-12-25 05:50:43
问题 What is the correct/idiomatic way to loop through JSON objects that only start with a certain pattern? Example: say I have a JSON like { "END": true, "Lines": "End Reached", "term0": { "PrincipalTranslations": { // nested data here } }, "term1": { "PrincipalTranslations": { // more nested data here } } } I only want to access the PrincipalTranslations object and I tried with: $.each(translations, function(term, value) { $.each(term, function(pos, value) { console.log(pos); }); }); Which doesn

Get the href value of a previous HTML anchoer, <a>, using jQuery

纵饮孤独 提交于 2019-12-25 05:28:16
问题 I am trying to get the value of href of <a> that is the previous element to my current button that is clicked. How do I get it? Here is my code. HTML: <a href="#activityNotes[0].noteText"> <input value="Add Another" name="addAnotherNote" type="submit" class="addAnother secondary" onclick="addAnotherNote();"/> </a> jQuery: $(".addAnother").click(function() { var jump = $(this).prev("a").attr("href"); }); When I try running this, I get jump value undefined. Why is this happening? Is it because

Getting div id values from a string and manipulating it

雨燕双飞 提交于 2019-12-25 04:39:19
问题 How do I implement this? I have a variable with comma separated div names. After an AJAX request I have to hide all the divs parsed from the string. So how do I parse the string to get individual div name and hide it? jQuery code var dragExternal = 'div1a,div1b,div2a,div2b'; $.ajax({ type: 'POST', url: "index.html", data: dragExternal, processData: false, success: function(data) { alert("Success"); //Start of code to hide all the div's parsed from the string $('#div1a').slideUp(90); }, error:

is there a toggleSrc method in jQuery?

半城伤御伤魂 提交于 2019-12-25 04:26:46
问题 Does jQuery have something like toggleSrc :-p ?? I want to change src of an image on slideToggling of a div.is there something like that give me the chance of not writing conditional statement to check the src of image to change to another src. (I am not lazy !!!) 回答1: There isn't a built-in method for this, but you could make a plugin for it, for example: $.fn.toggleSrc = function(onSuffix, offSuffix) { return this.attr("src", function(i, src) { return src.indexOf(onSuffix) != -1 ? src

Jquery returns b.fn.b.init[102]

十年热恋 提交于 2019-12-25 04:17:24
问题 I have to select multiple elements, all them have the class ="org-box". Inside that box there is a link a that I want to capture the href. So I do this $("a.org-box").click(function (e) { e.preventDefault(); var link = $(e).html(); $('.col-right').prepend("<b>" + link +"</b>"); }) What I always get is null, and I have tried other selectors like var link = $(e.a).attr("href").html(); With the same luck. I checked what I get from that selection $("a.org-box") and I get this -> b.fn.b.init[102]