Bạn đang xem : thuộc tính jquery get của phần tử được nhấp
Tôi đang sử dụng jQuery để nhận được nhấp chuột vào phần tử ‘a’. Tôi có một danh sách các liên kết trong đó mỗi liên kết có một lớp mà tôi đang nhấp vào.
Tôi muốn biết liên kết nào đã được nhấp vào (tôi có thuộc tính ‘setid’ cho mỗi liên kết) và cũng biết được điểm mà con chuột đã được nhấp.
Làm cách nào để có thể thực hiện được điều này?
ví dụ về mã:
& lt; a href = "#" class = "newItem" setid = "28" & gt; nhấp vào tôi & lt; / a & gt;
$ ('. newItem'). click (function (e) {
alert (e.attr ('setid'));
});
CHỈNH SỬA:
Được rồi, để có được vị trí, tôi sẽ sử dụng e.pageX
Xem thêm những thông tin liên quan đến chủ đề thuộc tính jquery get của phần tử được nhấp
jQuery attribute value selector
- Tác giả: kudvenkat
- Ngày đăng: 2015-03-26
- Đánh giá: 4 ⭐ ( 9988 lượt đánh giá )
- Khớp với kết quả tìm kiếm: Link for all dot net and sql server video tutorial playlists
https://www.youtube.com/user/kudvenkat/playlists?sort=dd&view=1Link for slides, code samples and text version of the video
http://csharp-video-tutorials.blogspot.com/2015/03/jquery-attribute-value-selector.htmlHealthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1In this video we will discuss
Attribute Equals Selector [name=”value”]
Attribute Not Equal Selector [name!=”value”]
Attribute Contains Selector [name*=”value”]
Attribute Contains Word Selector [name~=”value”]
Attribute Contains Prefix Selector [name|=”value”]
Attribute Starts With Selector [name^=”value”]
Attribute Ends With Selector [name$=”value”]This is continuation to Part 7, please watch Part 7 before proceeding.
$(‘[title=”div1Title”]’) // Selects all elements that have title attribute value equal to div1Title
$(‘[title!=”div1Title”]’) // Selects all elements that have title attribute value not equal to div1Title
$(‘[title*=”Title”]’) // Selects all elements that have title attribute value containing the given substring – Title
$(‘[title~=”mySpan”]’) // Selects all elements that have title attribute value containing the given word – mySpan, delimited by spaces
$(‘[title|=”myTitle”]’) // Selects all elements that have title attribute value equal to myTitle or starting with myTitle followed by a hyphen (-)
$(‘[title^=”div”]’) // Selects all elements that have title attribute value starting with div
$(‘[title$=”Heading”]’) // Selects all elements that have title attribute value ending with HeadingSelects all elements that have title attribute value equal to div1Title and sets 5px solid red border
[html]
[head]
[title][/title]
[script src=”Scripts/jquery-1.11.2.js”][/script]
[script type=”text/javascript”]
$(document).ready(function () {
$(‘[title=”div1Title”]’).css(‘border’, ‘5px solid red’);
});
[/script]
[/head]
[body]
[div title=”div1Title”]
DIV 1
[/div]
[br /]
[div title=”div2Title”]
DIV 2
[/div]
[p title=”myTitle-paragraph”]
This is a paragraph
[/p]
[p title=”myTitleHeading”]
This is a paragraph
[/p]
[span title=”div1Title”]
SAPN 1
[/span]
[br /][br /]
[span title=”mySpan Heading”]
SPAN 2
[/span]
[/body]
[/html]Selects all div elements that have title attribute value not equal to div1Title and sets 5px solid red border
[script type=”text/javascript”]
$(document).ready(function () {
$(‘div[title!=”div1Title”]’).css(‘border’, ‘5px solid red’);
});
[/script]THIS IS
$(‘div[title!=”div1Title”]’).css(‘border’, ‘5px solid red’);
EQUIVALENT TO
$(‘div:not([title=”div1Title”])’).css(‘border’, ‘5px solid red’);Selects all elements that have title attribute value containing the given substring – Title, and sets 5px solid red border
[script type=”text/javascript”]
$(document).ready(function () {
$(‘[title*=”Title”]’).css(‘border’, ‘5px solid red’);
});
[/script]Selects all elements that have title attribute value containing the given word – mySpan, delimited by spaces, and sets 5px solid red border
[script type=”text/javascript”]
$(document).ready(function () {
$(‘[title~=”mySpan”]’).css(‘border’, ‘5px solid red’);
});
[/script]Selects all elements that have title attribute value equal to myTitle or starting with myTitle followed by a hyphen (-) and sets 5px solid red border
[script type=”text/javascript”]
$(document).ready(function () {
$(‘[title|=”myTitle”]’).css(‘border’, ‘5px solid red’);
});
[/script]Selects all elements that have title attribute value starting with div and sets 5px solid red border
[script type=”text/javascript”]
$(document).ready(function () {
$(‘[title^=”div”]’).css(‘border’, ‘5px solid red’);
});
[/script]Selects all elements that have title attribute value ending with Heading and sets 5px solid red border
[script type=”text/javascript”]
$(document).ready(function () {
$(‘[title$=”Heading”]’).css(‘border’, ‘5px solid red’);
});
[/script]
Get / Set thuộc tính thông qua JS DOM
- Tác giả: hanoiict.edu.vn
- Đánh giá: 4 ⭐ ( 2050 lượt đánh giá )
- Khớp với kết quả tìm kiếm: Trong bài hướng dẫn tự học lập trình JavaScript này, bạn sẽ tìm hiểu cách get, set và xóa các thuộc tính khỏi các thành phần HTML trong JavaScript với JS DOM.
Thuộc tính trong jQuery
- Tác giả: vietjack.com
- Đánh giá: 4 ⭐ ( 5778 lượt đánh giá )
- Khớp với kết quả tìm kiếm: Thuộc tính trong jQuery – Học jQuery cơ bản và nâng cao theo các bước đơn giản về jQuery Selector, Bộ chọn, thuộc tính, Attribute, CSS, Thao tác DOM, Truy cập DOM, AJAX trong jQuery, hiệu ứng, sự kiện trong jQuery, Drag và Drop, Effect, Event Handler, UI, Plug-ins và các tiện ích khác trong jQuery.
Lấy giá trị và thiết lập giá trị thuộc tính phần tử HTML bằng jQuery
- Tác giả: vnxf.vn
- Đánh giá: 5 ⭐ ( 4965 lượt đánh giá )
- Khớp với kết quả tìm kiếm: Lấy giá trị và thiết lập giá trị thuộc tính phần tử HTML bằng jQuery
Chúng ta có thể tương tác lấy, gán giá trị cho thuộc tính HTML (href, src, id, class…
Sử dụng phương thức Get
- Tác giả: hiepsiit.net
- Đánh giá: 5 ⭐ ( 3618 lượt đánh giá )
- Khớp với kết quả tìm kiếm:
Thuộc tính trong jQuery
- Tác giả: quantrimang.com
- Đánh giá: 3 ⭐ ( 3508 lượt đánh giá )
- Khớp với kết quả tìm kiếm: Một số thành phần cơ bản nhất, chúng ta có thể thao tác với các phần tử DOM, là các đặc tính và các thuộc tính được gán cho các phần tử đó.
jQuery Selectors – Chọn phần tử trong Jquery
- Tác giả: quachquynh.com
- Đánh giá: 4 ⭐ ( 6945 lượt đánh giá )
- Khớp với kết quả tìm kiếm:
Xem thêm các bài viết khác thuộc chuyên mục: Kiến thức lập trình