SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Nov 2010
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how is search to a selector for find a value by jQuery?

    how is search to a selector for find a value by jQuery?

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Do you mean an element with a certain value for a certain attribute?

    Code:
    $('input[value="foo"]')
    This will find all inputs with value="foo".

    More info: Selectors – jQuery API

  3. #3
    Non-Member
    Join Date
    Nov 2010
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i want a value( $("#hotel").val(); ) search to some of selector(.list_name p):

    Code JavaScript:
    var strToMatch = $("#hotel").val();
    $('.list_name p').each(function () {
                if (this.innerHTML.indexOf(strToMatch) > -1) {
                    $(this).show();
                    if($('#hotel').val()==""){
                        $('.list_name p').hide()
                    }                
                } else {
                    $(this).hide();
                }
            });

    this:
    Code JavaScript:
    this.innerHTML.indexOf(strToMatch) > -1
    how is with jQuery?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by binboy View Post
    how is with jQuery?
    The jQuery selectors page shows one called :contains() which seems like it should do the job for you.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •