0

単純な検索エンジンの問題..

簡単な検索エンジンを作成していますが、その方法がわかりません。だからここに私が試したことがあります。

姓/名に基づいて結果を取得する必要があります..

JSFiddle : http://jsfiddle.net/WSPbP/

JS

$(document).ready(function() {

    $('#sbutn').click(function() {
        $v = $('#searchbox').val();
        console.log($('#myConnections >div').find("div:contains("+$v+")"));
    });
});

HTML

<div id="searchelement">
    <div class="search"><input type="text" name="search" id="searchbox" value="" /></div>
    <div class="searchbutton" id="sbutn"><button type="button">Search</button></div>
</div>
</br>
<div id="myConnections">

    <div class="left" style="width:100px; height:100px;">
        <img style="width:70px; height:70px;" src="picture1.jpg" alt=""><br>
    person1_xyz         

    </div>

    <div class="left" style="width:100px; height:100px;">
        <img style="width:70px; height:70px;" src="picture2.jpg" alt=""><br>
    person2 abc         

    </div>
</div>
4

1 に答える 1

1

の値を引用していません:contains

$(document).ready(function() {
   $('#sbutn').click(function() {
      $v = $('#searchbox').val();
      console.log($('#myConnections').find("div:contains('"+$v+"')").text());
   });
});​

デモ

于 2012-04-11T11:35:58.723 に答える