如何使用jQuery和element读取Django
请参阅图像plx
,我在django上设置了一些可读字段,但是我想使用jQuery读取值,但实际上是IDK,我想做它,我想做这件事,取决于在“ Tipo”字段上设置的值,我想要一定的值visibles。
let tipo_persona_check = function(){
if ($('#id_tipo').val() == 'fisica'){
$('.field-empresa').hide();
$('label[for=id_persona').text('Suscriptor');
}else{
$('label[for=id_persona').text('Apoderado');
$('.field-empresa').show();
}
在这种情况下,我会根据ID_TIPO的值隐藏或显示字段Empresa,但是当它在ReadOnly上时,此ID不存在,只有一个跨度类称为readOnly(所有Readonly),但IDK如何获得。从中,我需要知道该值是“ fisica”还是从Readonly Field Tipo中进行的,才能做事。
有什么想法吗?
see the image plx
there are some readonly field that i set up on django, but i want to read the values using Jquery but really idk how to do it, i want to do it cuz depending of the value that is set on field "tipo" i want a make some values visibles or not.
let tipo_persona_check = function(){
if ($('#id_tipo').val() == 'fisica'){
$('.field-empresa').hide();
$('label[for=id_persona').text('Suscriptor');
}else{
$('label[for=id_persona').text('Apoderado');
$('.field-empresa').show();
}
in this case im hidding or showing field empresa depending of the value of id_tipo, but when it is on readonly, this id not exist, there is just a span class called readonly (for all readonly) with the value, but idk how to get from it, i need to know if the value is "fisica" or another from the readonly field tipo, to do things.
any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有检查
id
在这种情况下是否真的可见我们假设没有看到ID。
解决方案是您可以在该节中添加
输入
,以便从中找到ID。和您的JS文件:
I did not check whether the
ID
is really visible when this is the caseWe assume that the ID is not seen.
The solution is that you can add an
input
in that section so that you can find the ID from it.and in you js file: