如何从jquery中的div标签获取数据?(How can I get the data from a div tag in jquery?)

编程入门 行业动态 更新时间:2024-10-25 04:26:05
如何从jquery中的div标签获取数据?(How can I get the data from a div tag in jquery?)

我正在尝试使用jQuery获取数据事件值,然后更改div的背景颜色。 这是我目前的情况:

<div class="fc-content" title="" data-events="Work In Progress"></div>
jQuery(document).ready(function($) {
    $("div[data-events='Work In Progress']").next().css('background-color:','#000000;'); 
});
 

目的是因为我想过滤某些值为“正在进行中”的事件并将背景颜色更改为黑色。

I'm trying to get the data-events value using jQuery and then change the background color of the div. This is my current situation:

<div class="fc-content" title="" data-events="Work In Progress"></div>
jQuery(document).ready(function($) {
    $("div[data-events='Work In Progress']").next().css('background-color:','#000000;'); 
});
 

The purpose is because I want to filter certain events that have a value of 'Work In Progress' and change background-color to black.

最满意答案

您可以通过执行以下操作来获取div:

var eventInProgress = $("div[data-events='Work In Progress']"); eventInProgress.css("background-color", "#000000");

You can get the div by doing the following:

var eventInProgress = $("div[data-events='Work In Progress']"); eventInProgress.css("background-color", "#000000");

更多推荐

本文发布于:2023-07-23 12:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1231630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标签   数据   div   jquery   data

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!