2017-01-19 15 views
0

こんにちは私は、下記の例button textの場合、すなわち(そのbutton textボタンのテキストを一致させて要素を折り返す方法は?

に対応するので、私はbutton textがされdiv classnewとして及び場合"Upload" を追加しています"Download"あるとbuttonappenddivにしようとしています私はappendいくつか他のdiv class)。

appending divについてはwrap APIを使用しています。

は、ここに私のコード

<!DOCTYPE html> 
 
<html> 
 
<head> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
</head> 
 
<body> 
 
    <button class="btn" title="run">Download</button> 
 
    <script> 
 
    $(document).ready(function() { 
 
     var buttontext = $("button").text(); 
 
     alert(buttontext); 
 
     $('button[text="Download"]').wrap("<div class='new'></div>"); 
 
    }); 
 
    </script> 
 
</body> 
 

 
</html>

である私は、このようなbutton[text="Download"]button textを取得しようとしていますが、それは動作しません。

最後に、私はこの

<div class="new"> 
 
    <button class="btn" title="run">Download</button> 
 
</div>

のような出力が何か任意の助けが理解されるであろう欲しいです。

答えて

関連する問題