On Thu, Aug 28, 2008 at 2:58 AM, velij <[EMAIL PROTECTED]> wrote:
>
> Hi everyone, this is my first message to the jquery group, hope you
> don't mind and i'll improve over time :)
Welcome! We're here to help, and we hope to improve ourselves as well, with
your help :)
>
> My HTML is this:
>
> <ul id="gallery">
> <li>
> <h2><a href="#targeturl">www.targetlink.com.whatnot</a> Title</h2>
> <img src="thumb.jpg" alt="" />
> <p>Lorem impsum
> </p>
> </li>
>
>
> First i'd like to find the IMG tag from every #gallery LI to apply a
> hover function to the image inside the specifil ul that has been
> hovered.
>
> I tried different versions, and thought this one would be ok, but not
> working....
>
> $("#gallery li").hover(
> function(){
> $(this,"img").addClass("over")
> }
> }
You've got these two params switched. To find all the img tags, but have the
query context be the element in 'this' (instead of the default - document)
you want:
$("img", this)
Another way to do this is
$(this).find("img")
>
>
> Secondly i'd like the heading H2 inside the LI to change when i hover
> it, i got it partly working, it changes when i hover, but i'd like it
> to return to it's original state after that. The code i use ise here:
> $("#gallery li h2 a").hover(
> function(){
> $(this).replaceWith("<a href=#the_same_link_as_it_was_before>I
> am
> the changed text</a>");
> },
> function () {
> $(this).replaceWith(this).text;
> }
> )
Something like this should do:
$("#gallery li h2 a").hover(
function(){
$(this).data("savetext", $(this).text())
.text("I am the changed text");
},
function () {
$(this).text( $(this).data("savetext") );
}
)
>
>
>
> and the last one i'm just puzzled with. I'd like to dynamically add a
> DIV element to the inside of an UL, just before ending the ul tag (</
> UL>) on mousover, which is quite easy, but i'd like to remove it on
> mouseout...
>
> My current code (which does nothing) goes like this:
>
> $("#gallery li").hover(
> function(){
> $(this).wrap('<span style="border:1px solid
> green;float:left;"></
> span>')
> .parent()
> .append('<div id="divver"></div>')
> },
> function () {
> $(this).css('borderColor','red')
> /*just for testing*/
> }
> )
Hmmm. The only valid element immediately inside a UL is an LI, so you've got
two problems above:
1) You're trying to wrap your LI in a span
2) You're trying to append a DIV to the UL
Neither are valid. Whether or not you get it to work in one or more
browsers, I would not recommend it for that reason.
>
> Thanks everyone for any guiding me in the right direction, I'm eager
> to learn more about jquery every day!
It's a real pleasure. Both are.
- Richard
Richard D. Worth
http://rdworth.org/