トップページ >  Ajax >  jQueryの基本的な関数 text()
初版2009/08/11: 最終更新日2009/08/11
jQueryの基本的な関数 text()
目次
jQueryの基本的な関数 text()
サンプルソース
実行例
jQueryの基本的な関数 text()
要素の中身をHTMLなしの文字列で返します。 要素が複数の場合結合して返します。
また、引数として文字列を与えた場合、中身をその文字列に更新します。
サンプルソース
<html>
<head>
<title></title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1.3");</script>
<script type="text/javascript">
$(document).ready(function(){
function execute_sample(selector){
    if( selector == undefined ){
        selector = '#sample';
    }
    var code = $(selector).html();
    eval(code);
}
</script>
</head>
<body>
    <input type="button" value="サンプル実行" 
    onclick="execute_sample('#sample_text')" /><br /><br />
    <span id="sample_text">alert( $("#sample").text() );</span><br /><br />
    <span id="sample">ここの文字列を表示します</span>
</body>
</html>
実行例
以下、実行例です。



alert( $("#sample").text() );

ここの文字列を表示します
Information
リンクについて
個人情報保護方針
Yahoo!ブックマークに登録

社長ブログ
やる気はあるがお金がない㈱コンフレッジブログ

広告
株式会社グローハウジング


サイト内検索
当サイト内を検索できます↓


PV