▼キーワードリンクをクリックすると、テキスト入力欄に、空白またはカンマ区切りでクリックしたキーワードを連結させます。
your tags: カンマ区切り
website: 空白区切り
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ja" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title>jQuery Plugin -- jTagging | 設置サンプル</title>
<link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
<!-- JS -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/content/lib/jquery/jQuery.jTagging.js"></script>
<script type="text/javascript">
$(function() {
$("#TagText1").jTagging($("#TagDiv1"), ",");
var tagDivList = new Array($("#TagDiv3"), $("#TagDiv4"));
var normalClass = { padding: "2px 1px 0 1px", textDecoration: "underline", color: "#f00", backgroundColor: "" };
var selectedClass = { padding: "2px 1px 0 1px", textDecoration: "underline", color: "#fff", backgroundColor: "#f00" };
var normalHoverClass = { padding: "2px 1px 0 1px", textDecoration: "none", color: "#fff", backgroundColor: "#00f" };
$("#TagText2").jTagging(tagDivList, " ", normalClass, selectedClass, normalHoverClass);
});
</script>
<!-- CSS -->
<style type="text/css">
div.box { border:1px solid #5ab500;margin:5px;padding:10px;background-color:#e6f7d4; }
</style>
<link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
<body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
<div id="wrap">
<h1><a href='http://www.alcoholwang.cn/jquery/jTagging.htm'>jQuery Plugin -- jTagging</a> | 設置サンプル</h1>
<p>▼キーワードリンクをクリックすると、テキスト入力欄に、空白またはカンマ区切りでクリックしたキーワードを連結させます。</p>
<!-- CODE -->
<h2>例1</h2>
<p>your tags: <input id="TagText1" size="65"> カンマ区切り</p>
<div id="TagDiv1" class="box"><a href="#" onclick="return false;">javascript</a> <a href="#" onclick="return false;">jquery</a> <a href="#" onclick="return false;">tag</a> <a href="#" onclick="return false;">cool</a></div>
<h2>例2</h2>
<p>website: <input type="text" id="TagText2" size="65" value="dianping"/> 空白区切り</p>
<div id="TagDiv3" class="box"><a href="#" onclick="return false;">Google</a> <a href="#" onclick="return false;">Yahoo</a> <a href="#" onclick="return false;">MSN</a></div>
<div id="TagDiv4" class="box"><a href="#" onclick="return false;">yelp</a> <a href="#" onclick="return false;">judysbook</a> <a href="#" onclick="return false;">dianping</a> <a href="#" onclick="return false;">Zagat</a></div>
<!-- CODE / -->
</div>
</body>
</html>