我試圖更改我的href值,但它似乎沒有任何變化。我已經嘗試了jQuery和JavaScript方法,都沒有工作。無法更改標籤的href值
<a type="button" class="view_me btn btn-primary" href="#">View Full</a>
$(document).on("click", ".click_row", function (e) {
e.preventDefault();
var _self = $(this);
userId = _self.data('id');
var newLink = '/users/view/' + userId //I'd like to eventually use this as new href link
$(".view_me").prop("href", "www.google.com"); // Tried testing with a simple webpage
// document.getElementById('view_test').href = "www.google.com"; // Tried this as well, doesn't work
console.log(newLink)
});
任何建議會有所幫助。我正在使用jQuery 3.2.1
'www.google.com'不是有效的URL。試試'http:// www.google.com'而不是 –
,其中'view_test'和'click_row' – guradio
'View Full'沒有id'view_test'。 –