jQuery Multiple ID selectors
Try this:
$("#upload_link,#upload_link2,#upload_link3").each(function(){
$(this).upload({
//whateveryouwant
});
});
jquery selector on multiple id
$("#prezzo,#quantita,#prodotto").each(function()
{
if ($(this).val() !="" )
{}
else
{}
});
Is there a more efficient way to combine multiple id selectors each with a child selector in jQuery?
Use .children()
$("#div1, #div2, #div3").children("input[type=checkbox]").click(function() {
// do stuff
});
jQuery - event target multiple id selectors?
Just use the id selectors to get each value and ignore the event object. The event object knows nothing about the other element. It only references the element the specific change occurred on
const value1 = $('#test-input').val(),
value2 = $('#input').val();
jquery multiple id selectors through php echo
Use class instead id ,change in html
<a class="clinks msgr" style="text-decoration: none; font-weight:bold;" id="msgr_<?php echo $d['qid'];?>" href="javascript:void(0)">message</a>
<div id="chatbox_<?php echo $d['qid'];?>" > </div>
And in JS
$(".msgr").click(function(){
var id = $(this).attr("id").split("_")[1];
$("#chatbox_"+id).fadeIn();
});
Added an example
$(".msgr").click(function(){ var id = $(this).attr("id").split("_")[1]; $("#chatbox_"+id).fadeToggle(); console.log("chatbox_"+id);});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div><a class="clinks msgr" style="text-decoration: none; font-weight:bold;" id="msgr_1" href="javascript:void(0)">message</a><div id="chatbox_1" >test1</div></div><div><a class="clinks msgr" style="text-decoration: none; font-weight:bold;" id="msgr_2" href="javascript:void(0)">message</a><div id="chatbox_2" >test2</div></div><div><a class="clinks msgr" style="text-decoration: none; font-weight:bold;" id="msgr_3" href="javascript:void(0)">message</a><div id="chatbox_3">test3</div></div>
Handling multiple IDs in jQuery
Yes, #id
selectors combined with a multiple selector (comma) is perfectly valid in both jQuery and CSS.
However, for your example, since <script>
comes before the elements, you need a document.ready
handler, so it waits until the elements are in the DOM to go looking for them, like this:
<script>
$(function() {
$("#segement1,#segement2,#segement3").hide()
});
</script>
<div id="segement1"></div>
<div id="segement2"></div>
<div id="segement3"></div>
Multiple ID jQuery Selector returns different than when a single ID selector
Because with this selector :
#racksTab,#condenserTab,#glycolTab .dropdown-menu li a
You are targeting three elements:
Element with Id
racksTab
Element with Id
condenserTab
a
element insideli
child of.dropdown-menu
child of Id elementglycolTab
I guess you want all elements like the third one, so your selector must be:
#racksTab .dropdown-menu li a, #condenserTab .dropdown-menu li a, #glycolTab .dropdown-menu li a
Note: Maybe you don't need those selectors at all, I think you can improve your code with a more suitable selector as @j08691 points on the comments, but all will be based on the real markup, if you add it we can help U improve the code.
jQuery selector: Select multiple ID and get their values
Additionally to what VisioN said. I would like to encourage you to use classes for this purpose:
<div class="item" id="item1"></div>
<div class="item" id="item2"></div>
<div class="item" id="item3"></div>
<div class="item" id="item4"></div>
<div class="item" id="item5"></div>
And
$(".item").mouseout(...)
JQUERY Selector not working on multiple ids with same name
From the jQuery API Documentation:
id selector
Description: Selects a single element with the given id attribute.
If you wish to select multiple elements, you could give them all the same class="test"
and then use:
$(".test").click(function(){
$("#div1").load("test.php?" + $(this).attr("albid"));
});
Note the use of $(this)
inside the function.
Jquery ID selector doesnt work when multiple IDs are given
DEMO
You cannot have multiple id's
for a element.
because the browser will only render the first one
$("#inp").val($("#index").length); //sets value 1
^ //add $ here
Read
Can a HTML element have multiple unique ID attributes?
id attribute
Related Topics
Using Lodash .Groupby. How to Add Your Own Keys for Grouped Output
Password-Check Directive in Angularjs
Where Should Ajax Request Be Made in Flux App
How to Set Image Source with Base64
Open Page in New Window Without Popup Blocking
Trying to Use the Domparser with Node Js
Add Cors Header to an Http Request Using Ajax
JavaScript Design Pattern: Difference Between Module Pattern and Revealing Module Pattern
Fade in on Scroll Down, Fade Out on Scroll Up - Based on Element Position in Window
JavaScript Library for Human-Friendly Relative Date Formatting
Why Do Arrow Functions Not Have the Arguments Array
What Is the Meaning of an Underscore in JavaScript Function Parameter
JavaScript Es6 Cross-Browser Detection
Filtering an Array with a Function That Returns a Promise
Es6 Promises - Something Like Async.Each
Difference Between Dot Notation and Bracket Notation in JavaScript
Auto-Refreshing Div with Jquery - Settimeout or Another Method
How to Get the Back Button to Work with an Angularjs Ui-Router State MAChine