The reason is that we can do
$('<div>some text</div>').prependTo('#someDiv')
so, this is also ok to do:
$('some text').prependTo('#someDiv')
but we can't change some text to body? body is just as good as any text...
(the above code is adding some text to the div with id someDiv, so what if I want to add the word body to the div?)...
Hey all. Basically, I want the the next image to be clicked using jquery every second:
jQuery:
var i=1;
setInterval(function() {
$(".portfolio :nth-child("+i+")").click();
if (i<5) {i++;} else {i=1;}
}, 1000);
HTML:
<div class="portfolio">
<ul>
<li><img src="images/4.jpg" alt="4" id="promo_one"></li>
<li><img src...
I am looking for a generalised selector function that does the following:
$(".data").click(function(){
//insert proper selector
)};
<div class="one">
<div class="data">text</div>
<div class="data">text</div>
<div class="data">text</div>
</div>
<div class="two">
<div class="data">text</div>
<div class="data">text</div>
<div class="d...
Hi all,
Using jQuery, I've got a selector -- call it $('#someDiv1') -- that I'd like to get the inner HTML for, but also the header of the tag as well. So given this HTML structure..
<div id="parentDiv">
<div id="someDiv1">
<div id="innerDiv1_1"></div>
<div id="innerDiv1_2"></div>
</div>
<div id="someDiv2">
...
I wrote some jQuery to select the cells from a table with a certain class; in this case, "hello". However, the table has nested tables with a column of the same class. How do I select the cells from the outer table but not select the cells from the inner? See below:
HTML:
<table class="foo"> <!-- this is the outer table
<tbody>
...
There must be a better way to select this element. Can someone please help me out. I've tried nth-child and last-child, but I'm not getting it.
Here's my code:
<li>
<div class="pic" style="width:300px; text-align:center;">
<img src='path/to/my/image.jpg' />
</div>
<p>
<span title="<?php echo $media_title; ...
Hello all
I am stuck in a selector problem in JQuery. I have the following html structure ....
<table>
<tr>
<td rowspan="3"></td>
<td></td>
<td></td>
<td rowspan="3"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td rowspan="4"></td>
<td></td>
<td></td>
<td rowspan="4"></td>
</tr>
<tr>
<td></td...
I have a problem. I have a div component where I'll drag multiple images. This part is working perfectly. But I am not able to read the order of these images played in the component. What happens, I can play any position in the image of the div component, however, like to read in order as they are, from left to right.
I believe it is po...
Given this sample markup (assuming a random number of elements between .outer and .inner:
<div class="outer">
<div>
<div>
<div class="inner"></div>
</div>
</div>
</div>
I can set up jQuery to select the outer and inner divs as such:
$outer = $('.outer');
$inner = $outer.find('.inner')
Works fine....
I'm writing a basic app which involves changing the html in divs referenced by name, and it's working fine in Chrome, Firefox, Safari, etc. but not in our beloved Internet Explorer. I'm loading the content dynamically so I can't give you full code but here's an example of the HTML (where there would be many such divs stacked with ascend...
I have several Div's that appear and would like each one to have a "delete" button on it. When a user clicks on the delete I have a modal come up with 2 choices, either confirm the delete or cancel.
THE QUESTION is: How can I adapt my code below so that only the parent div that I've selected to trigger the modal get's deleted? An array...
I have a jquery function which makes an ajax call to a webservice method on the web server, the method returns a html table with data. I am using .html() to render the return values on div. This works in Firefox,Chrome, Safari but does not work on IE8
$.ajax({
type: "POST",
url: "./../WebAjaxCalls.asmx/GetProductInstruction",
...
Hi all,
After working in good ole' c++ all day, I like to have a few javascript/jQuery side projects that are purely for fun. One of most intriguing things about jQuery is the ease of filling forms. All you need is a selector and the .val() method and you are golden. However, what would be the most efficient way to fill forms across mul...
So I have an issue, when I load a document, I have a class called .active which changes depending on what list item you are viewing using keyboard navigation. The problem is when that list item has the class active assigned to it, I would like that list item only, on hover, to display another piece of content.. But the problem is, I beli...
I have a several forms, and I'd like to select only the first and second input box of each form
$("form input:nth-child(1), form input:nth-child(2)");
But this doesn't work because each input has a label next to it, so there is no input that is nth-child(1).
Example at jsbin
...
I have a jQuery script that creates a carousel to rotate images left and right on user click. At first, I wasnt planning on putting more than one carousel on a single page, but now the need has arrived.
The problem is, I dont know how to refer to one carousel (the one clicked) when the user clicks a button.
Heres the script
$(functio...
Possible Duplicate:
attribute value
I have an atribute test that I get the value of like this
$('#row').attr("test"); //this works
now I need to put this in a loop and get the value but its not working. This is what I am doing
for(var i=0; i=mySpansCount; i++)
{
alert($('#row').attr("test")[i);
}
All I am getting in al...
Just curious if there is an established "best way" to target child elements inside of a parent element.
For example, if I want to create a click event on the children of a parent element, which one should be preferred?
a) give the parent element and id and do:
$('ul#parent li').click(function() {});
b) or, instead, give each of the c...
I have a form with a table in it. In each row is a table cell with a hidden input item with the name of it starting with "hf_id_" followed by a number so that row 1's field has a name of "hf_id_1", row 2 is "hf_id_2" and so on. I need to search all of these fields for a particular value but I'm not quite sure how to get to the hidden f...
How do I select an <a href="...">foo</a> DOM node, knowing foo?
...