Skip to content
Loading
 
+1
  • +1
    Hi ,
     
    Below code will help you
     
     $(document).ready(function () {
                console.log($('#languages').children('li:first').text());
                //Result Java
                console.log($('#web').children('li:first').text());
                //Result JavaScript
                 console.log($('#languages').children('li:last').text());
                //Result List
            });
    +1
  • Faisal Pathan
    +1
    In simple words, selectors mean you can select particluar HTML element by id, name or element itself, Here, your selectors are languages, web and functional and also you can use ul and li as selectors.
    +1
  • Harsh Shah
    +1
    Hi
    Javascript uses the CSS syntax to select and manipulate HTML elements. Selectors are used to select HTML element based on their id, class name, tag name, attributes, types etc.
     
    You can find a small demo here which i have created for you based on code you have mentioned above. so find it on this link: https://jsfiddle.net/9bm4khsr/11/
     
    i have used code which you have provided but with some modification. i have used two lists and two button. when user click on add backend language button, new li will generate and will add to UL with id languages.similarly it will happen to the UL with id web.
     
    So this way you can select and manipulates HTMl element with the help of javascrip.
    Hope this will help you.
    Thank you. 
    +1
  • Sandhiya Priya
    0

    In your HTML, the main jQuery selectors are:

    • ID selectors ? $("#languages"), $("#web")

    • Class selector ? $(".functional")

    • Tag selector ? $("li"), $("ul")

    • Descendant/child selectors ? $("#languages li"), $("#languages > li"), $("#web li")

    • Positional selectors ? $("#languages li:first"), $("#languages li:last"), $("#languages li:eq(1)")

    These let you target elements by id, class, tag, hierarchy, or position.

    0