下面是這個插件的文件(這裏只有兩種功能。) http://tkyk.github.com/jquery-history-plugin/#documentation這個函數中的問號是什麼意思?
$(document).ready(function() {
function load(num) {
$('#content').load(num +".html");
}
$.history.init(function(url) {
load(url == "" ? "1" : url);
});
$('#ajax-links a').live('click', function(e) {
var url = $(this).attr('href');
url = url.replace(/^.*#/, '');
$.history.load(url);
return false;
});
});
這裏的HTML:
<body>
<h1>jQuery History Plugin Ajax Sample</h1>
<div id="ajax-links">
<ul>
<li><a href="#1">load 1.html</a></li>
<li><a href="#2">load 2.html</a></li>
<li><a href="#3">load 3.html</a></li>
</ul>
<div id="content"></div>
<hr />
</div>
<p>[<a href="../">All samples</a>] [<a href="http://github.com/tkyk/jquery-history-plugin">Project home</a>]</p>
</body>
可能的重複:http://stackoverflow.com/questions/1771786/question-mark-in-javascript http://stackoverflow.com/questions/1688337/javascript-if-alternative http://stackoverflow.com/問題/ 3322704/javascript-notation http://stackoverflow.com/questions/4278232/javascript-explanation-of-and http://stackoverflow.com/questions/6813840/what-does-this-javascript-code-do – JJJ
這是javascript的基本三元運算符http://msdn.microsoft.com/en-us/library/be21c7hw(v=vs.94).aspx – Devjosh
[Javascript Ternary運算符](http:// stackoverflow。 com/q/1788917/693207) –