当div没有div的id时获取内容...只有类 [英] get the content when the div does not have the id of the div ... only has the class

查看:412
本文介绍了当div没有div的id时获取内容...只有类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好。我有一张列出日子的表格。这些天在< div> 内,但我没有< div> 的I​​D。我试图获取< div> 的内容,但它仍然失败,就像我尝试获取值时一样。

Good afternoon. I have a table listing days. These days are within a <div>, but I do not have an ID for the <div>. I tried to get the contents of the <div> but it still fails, as it does when I try to get the value.

这是< div> 的一个示例我正试图获得该类。

This is an example of the <div> I'm trying to get the class of.

<div class="fc-day-number">6</div>`

我正在尝试使用Seguito函数获取此值,但我没有获得内容div的值..

I'm trying to get this value with the Seguito function but am not getting the value of the content div ..

$(".fc-widget-content").click(function () {
var diaSelecionado = $('.fc-day-number').val();
        alert(diaSelecionado);
    });
});


推荐答案

而不是 val() ,使用 .html()返回元素的 innerHTML 属性:

Instead of val(), use .html() to return the element's innerHTML property:

$(".fc-widget-content").click(function () {
var diaSelecionado = $('.fc-day-number').html();
        alert(diaSelecionado);
    });
});

这篇关于当div没有div的id时获取内容...只有类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆