[英]Get the url parameters and display it on jquery dialog box
美好的一天
我通常使用PHP進行操作,當我進入這個jQuery UI時,這是一個很好的功能,我遇到了一些問題。 我對javascript和jquery環境還很陌生,但仍在應付它的工作方式。
我的目標是將參數從鏈接傳遞到jquery對話框並在其中顯示該詳細信息。
HTML錨標簽
<td><a href="#?ID=<?php echo $row ['ID']; ?>" id="showdialog"><?php if ($row ['AFFILIATION'] == FALSE) { echo "D"; } else { echo $row ['AFFILIATION']; } ?></a></td>
JQUERY對話框
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
modal: true,
resizable: false,
height: 380,
width: 280
});
$("a#showdialog").click(function(){
$("#dialog").dialog("open");
});
</scipt>
我已經在網上閱讀了很多線程,但是由於我還是js的新手,所以我不確定使用哪個線程,也不確定如何將其放入對話框中。
非常感謝您的建議。
您可以使用$(this).attr('href');
獲取href或鏈接地址
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
modal: true,
resizable: false,
height: 380,
width: 280
});
$("a#showdialog").click(function(){
// Use this to get href
var href = $(this).attr('href');
$("#dialog").append(href)
$("#dialog").dialog("open");
});
</scipt>
如果您只想顯示ID,則需要拆分href
$('a').on('click', function(e) {
e.preventDefault();
var href = $(this).attr('href');
href = href.substring(2,href.length);
var items = href.split('=');
console.log(items);
});
items[1]
將僅包含數字。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.