0
<ul>
    <li class="first"><a href="#">Modify search</a>

    </li>
    <li><a href="#">For <span>Select</span><span style="float:right; padding-right:10px;">▼&lt;/span></a>

        <ul> <span><a href="#">Girlfriend</a></span>  <span><a href="#">Boyfriend</a></span>  <span><a href="#">Husband</a></span>  <span><a href="#">Wife</a></span> 
            <span class="cl"></span> <span><a href="#">Mother</a></span>  <span><a href="#">Father</a></span>  <span><a href="#">Daughter</a></span>  <span><a href="#">Son</a></span> 
                <span class="cl"></span> <span><a href="#">Friend (M)</a></span>  <span><a href="#">Friend (F)</a></span>  <span><a href="#">Colleague (M)</a></span>  <span><a href="#">Colleague (F)</a></span> 
                    <span class="cl"></span> <span><a href="#">Nephew</a></span>  <span><a href="#">Niece</a></span>  <span><a href="#">Aunt</a></span>  <span><a href="#">Uncle</a></span> 
                        <span class="cl"></span>
        </ul>
    </li>
</ul>

私がやろうとしているのは、値を選択するたびに、その値を強調表示して、フィルターに表示する必要があるということです。

たとえば、ガールフレンドを選択した場合、For:selectはFor:girlfriendのようになります。

4

7 に答える 7

0

「選択」テキストにはid「select_id」があると思います。

$('ul span').click(function(){

$("#select_id").html($(this).html);



});
于 2013-03-18T10:37:01.483 に答える
0
$('a').click(function(){

  var clicked_link = $(this).text() // will get the text 
  $(this).attr('some_attr') // will get the value of an attribute in the clicked a tag

alert(clicked_link);
})
于 2013-03-18T10:35:25.973 に答える
0

スパンする ID を追加します<span id="this">Select</span>

次に、getElementByI("this").innerHTML =必要なものに設定します

于 2013-03-18T10:35:55.197 に答える
0

スパンではなくli、内部のみを持つ必要があります。ulその他は許可されていません。

ただし、おそらく探している答えは次のとおりです。

$('ul li ul span').click(function(){

     $('ul li span').eq(2).text($(this).text());

}

そして、これらすべては確かにクラスまたは ID の使用を求めます。

于 2013-03-18T10:38:46.663 に答える
0

選択したアイテムを表示するスパンにid属性を追加します。getval

<span id="getval" style="float:right; padding-right:10px;">&#x25BC;</span>

JQuery

のテキストを取得し、anchor表示する場所に設定します。

$(document).ready(function(){
   $("ul span a").click(function(){
      $("#getval").text($(this).text());
   });
});
于 2013-03-18T10:37:54.707 に答える
0

要素にIDを割り当てることができれば簡単です...

例えば:

<a href="#">For <span id="select">Select</span>...

そして2番目にもul

<ul id="list">...

次に、次のようなものが必要です。

$('#list a').on('click', function() {
   var text = $(this).text(); //this take the text of the clicked text.
   $('#select').empty().text(text); //this assign the value.
});
于 2013-03-18T10:37:58.747 に答える
0

このようにしてください

$(function(){
 $("a").click(function() {
    alert("look like for : "+$(this).text());// OR show this value in any particular DIV
    $(".displayDiv").text("look like for : "+$(this).text());
  });
});
于 2013-03-18T10:38:02.470 に答える