This works perfectly for me in Fx2.0.0.5 Stef.

You are correct though - where you use .insertAfter() it will insert the
provided content after every matching element, which is ALL .changeQty
elements.
You can use 'this' (not '$this') to only insert it after the element that
was clicked by changing the line of the inner function to:

$("<form class='newQty'>stuff here</form>").insertAfter(this);


I'm also not sure if insertAfter is the best thing to use - should i use
childElements?
If you're wanting to insert content into the DOM then you're going about it
the right way. If .insertAfter() achieves the effect you're looking for then
it's the right one.

If you still can't get it working can you give us a URL of a test page?
--rob


On 7/25/07, stef <[EMAIL PROTECTED]> wrote:


im trying to insert an html string (a form) into a div (at spot XXX)
when .changeQty is clicked. I can only use classes, not id's cause the
div repeats many times on the page

<div class='inline'><span class='currentQty'>Quantity: blah<span
class='changeQty'> (Change)</span></span>XXX</div>

the string is: "<form class="newQty">stuff here</form>"

the code i came up with so far is below. it doesnt work but firebug
doesnt give errors either ... i dont think i can
use .insertAfter(".changeQty") because then it will insert it after
every instance of that class it finds on the page. so maybe i should
replace it with $this? I'm also not sure if insertAfter is the best
thing to use - should i use childElements?

$(document).ready(function()
{
        $(".changeQty").click
        (
                function()
                {
                        $("<form class='newQty'>stuff here</
form>").insertAfter(".changeQty");
                }
        )



});




--
Rob Desbois
Eml: [EMAIL PROTECTED]
Tel: 01452 760631
Mob: 07946 705987
"There's a whale there's a whale there's a whale fish" he cried, and the
whale was in full view.
...Then ooh welcome. Ahhh. Ooh mug welcome.

Reply via email to