如何从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");
更多推荐
发布评论