Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

jquery selector help

  • 04-03-2009 7:52pm
    #1
    Registered Users, Registered Users 2 Posts: 872 ✭✭✭


    Hi,

    I have a menu like
    <ul id="nav">
    <li><a href="#">one</a><li>
    <li><a href="#">two</a><li>
    <li><a href="#">three</a><li>
    <li><a href="#">four</a><li>
    </ul>
    

    I need to select the fourth a tag and add extra css to it
    $("#nav > li:nth-child(4) > a").css("width:90px");
    

    i think the > a part is causing issues because if i remove it the css gets added to the 4th li item.

    Thanks for any help


Comments

  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    grahamor wrote: »
    Hi,

    I have a menu like
    <ul id="nav">
    <li><a href="#">one</a><li>
    <li><a href="#">two</a><li>
    <li><a href="#">three</a><li>
    <li><a href="#">four</a><li>
    </ul>
    

    I need to select the fourth a tag and add extra css to it
    $("#nav > li:nth-child(4) > a").css("width:90px");
    

    i think the > a part is causing issues because if i remove it the css gets added to the 4th li item.

    Thanks for any help

    Firstly, I can't see any reason for either ">"

    Secondly, if removing the ">" works, why do you need help ?


  • Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭Placebo


    eh use

    .find()

    and then use .append for your forth tag


  • Registered Users, Registered Users 2 Posts: 872 ✭✭✭grahamor


    it was just a syntax error
    $("#primary-nav > li:nth-child(7) > a").css[B]({width:"90px"});[/B]
    

    instead of
    $("#primary-nav > li:nth-child(7) > a").css[B]("width:90px");[/B]
    

    Thanks anyway


Advertisement