<div id="book-now-div">Offer: Book Now and Pay Later</div>
<script>
// Get the data-booking-detail attribute value
var bookingDetail = document.getElementById("tourmaster-payment-template-wrapper").getAttribute("data-booking-detail");
// Check if the bookingDetail includes the specific tour ID
if (bookingDetail.includes('7568')) {
// Hide the div with id "book-now-div"
document.getElementById("book-now-div").style.display = "none";
}
</script>
您可以使用 CSS 根据 data-booking-detail 属性中是否存在特定数字来隐藏 div。然而,CSS 本身无法直接操作属性或其值。您需要使用 JavaScript 或 jQuery 来实现此功能。
以下是如何使用 JavaScript 实现此目的的示例:
<div id="book-now-div">Offer: Book Now and Pay Later</div> <script> // Get the data-booking-detail attribute value var bookingDetail = document.getElementById("tourmaster-payment-template-wrapper").getAttribute("data-booking-detail"); // Check if the bookingDetail includes the specific tour ID if (bookingDetail.includes('7568')) { // Hide the div with id "book-now-div" document.getElementById("book-now-div").style.display = "none"; } </script>