Jquery&Ruby - 切换功能不起作用(Jquery & Ruby - Toggle function not working)
有人可以告诉我为什么我的javascript代码不起作用
我正在使用gem simple_form,我想要做的是:
- 当用户点击红色框(如图中所示)时,空的红色框图像应更改为勾选框
- 我有2个CSS图像; img-checkbox-notick.png(无勾选框图片)&img-checkbox-tick.png(勾选框图片)
我正在使用javascript / toggle
new.html.erb
<div class="checkbox custom"> <%= f.input :remember_me, input_html: { class: 'css-checkbox' }, label_html: { class: 'css-label-notick' }, as: :boolean if devise_mapping.rememberable? %> </div>
javascript文件
$(document).ready(function() { $('.css-label-notick').on('click', function (e) { $('.css-label-notick').toggleClass(".css-label-tick"); }); });
我已在红色突出显示的图像中显示输入的详细信息
css文件
.css-label-notick { background: url("img-checkbox-notick.png") no-repeat; height: 65px; } .css-label-tick { background: url("img-checkbox-tick.png") no-repeat; height: 65px; }
任何建议将不胜感激 - 非常感谢
Could one kindly advise me why my javascript code is not working
i am using the gem simple_form, what i am trying to do is:
- when a user clicks on the red box (as displayed in the image) the empty red box image should change to a tick box
- i have 2 css images; img-checkbox-notick.png (none tick box image) & img-checkbox-tick.png (tick box image)
i am using javascript / toggle
new.html.erb
<div class="checkbox custom"> <%= f.input :remember_me, input_html: { class: 'css-checkbox' }, label_html: { class: 'css-label-notick' }, as: :boolean if devise_mapping.rememberable? %> </div>
javascript file
$(document).ready(function() { $('.css-label-notick').on('click', function (e) { $('.css-label-notick').toggleClass(".css-label-tick"); }); });
i have displayed the details of the input within the image highlighted in red
css file
.css-label-notick { background: url("img-checkbox-notick.png") no-repeat; height: 65px; } .css-label-tick { background: url("img-checkbox-tick.png") no-repeat; height: 65px; }
any advise would be much appreciated - many thanks
原文:https://stackoverflow.com/questions/32320791
更新时间:2022-02-20 15:02
最满意答案
每次执行时都会在开头设置指针。
ldi ZH,high(BCDTo7_Seg << 1) ldi ZL,low(BCDTo7_Seg << 1)
Every time it executes it sets pointer at the beginning.
ldi ZH,high(BCDTo7_Seg << 1) ldi ZL,low(BCDTo7_Seg << 1)
相关问答
更多-
从程序存储器中读取一系列数据 - AVR ATmega16(Reading a sequence of data from program memory - AVR ATmega16)[2022-04-11]
每次执行时都会在开头设置指针。 ldi ZH,high(BCDTo7_Seg << 1) ldi ZL,low(BCDTo7_Seg << 1) Every time it executes it sets pointer at the beginning. ldi ZH,high(BCDTo7_Seg << 1) ldi ZL,low(BCDTo7_Seg << 1) -
是的,这是可能的。 将--gc-sections传递给链接器将指示它省略未引用的部分。 此外,将-ffunction-sections和-fdata-sections标志传递给编译器将指示它为每个函数和变量生成一个部分,从而使这些部分在单独的基础上而不仅仅是在文件级别上。 Yes, this is possible. Passing --gc-sections to the linker will direct it to omit sections which are not referenced. Ad ...
-
AVR内存和intel十六进制(AVR memory and intel hex)[2023-02-20]
Intel十六进制使用字节地址。 PC程序计数器是指16位字地址。 如果您的单词地址是“实际地址”,那么只需加倍表示十六进制文件中该行起始地址的数字即可。 “复杂的内存结构”是什么意思? 无论地址空间如何分解,内存位置都需要唯一的地址。 我不熟悉程序存储器空间不以0开头并且线性延续,但如果有这样一个方案,intel hex文件中的一行可以指定从任何地址开始的任何连续存储器部分的内容。 编辑: intel hex文件的每行只能包含最多255个字节。 通常,数据被分成16或32字节的块。 每行包含块的起始地址( ... -
AVR开关输入(AVR Switch Input)[2022-09-12]
是的, tst chdir; brmi right tst chdir; brmi right看第7位,因为那是符号位。 当然有很多方法可以将其更改为#0位,但最简单的方法是使用bst和T标志: bst chdir, 0 ; copy bit to T flag, use any bit number you like brts right ; use brtc to reverse condition Yes, the tst chdir; brmi right looks at bit #7, b ... -
在装配中在ATmega16 EEPROM存储器上写入一些数字(Writing some numbers on ATmega16 EEPROM memory in assembly)[2022-04-29]
如果要在atmel studio中跟踪EEPROM,则需要启动调试会话并打开存储器窗口(Alt + 6)。 应该有下拉列表在哪里应该是eepom选项。 你可以在那里验证你的数据。 If you want to track EEPROM in atmel studio, than you need to start debug session and open memory window (Alt+6). There should be drop down list where should be eepom ... -
现在我解决了。 串行缓冲区的大小有问题。 我把它的大小增加到128个字节,现在工作正常。 Now i solved it. There is problem with size of serial buffer. I increased it's size to 128 bytes and its working fine now.
-
lcd与atmega16连接(lcd interfacing with atmega16)[2022-11-21]
我认为你没有执行所需的init序列。 在lcd_init()您首先发送函数集。 但是,显示器在此之前等待一个序列,如下所示: 我不确定如何使用4位接口处理,但我认为这就是为什么DB3-0“不关心”。 您可能只需要在4位总线上应用DB7-4(阅读数据表)。 我会在启动时等待几百毫秒,以确保Vcc稳定。 然后按照放松的时间跟随重置序列 打开 等待200ms 发送说明 等待20ms 发送说明 等待5ms 发送说明 等待5ms 发送功能集 ... 由于您没有轮询忙碌标志,我将在所有以下指令之间等待至少1ms。 I ... -
delay函数中有一个无限循环。 介意使用: delay: ldi r16, 0xFF delay_loop_1: dec r16 brne delay_loop_1 ret You have an infinite loop in your delay function. Mind using: delay: ldi r16, 0xFF delay_loop_1: dec r16 brne delay_loop_1 ret
-
AVR闪存读写(AVR flash memory reading and writing)[2021-08-23]
嗯..在Spi编程模式下有加载和写入指令。 首先,它们之间有什么区别? 您可能不知道“页面缓冲区”。 要将新数据写入页面,必须首先填充页面缓冲区。 它持有一个临时页面,必须逐字填写。 - >加载指令 缓冲区在一次操作中复制到闪存。 - >写指令 第二个问题是关于加载内存页面指令。 有两条指令:一条用于低字节,一条用于高电平。 我们必须发送四个字节:命令标识字节(如果我可以这样调用它),地址的MSB,地址的LSB和数据字节。 问题到底是什么指示呢? 虽然我们加载了由128个字节组成的页面,但这里的高低字节是什 ... -
AVR内部数据总线宽度(AVR Internal Data bus width)[2022-03-09]
Bit 8位AVR系列基于(经过修改的)哈佛架构,您可以在其中拥有专用的程序和数据存储。 程序存储器的数据路径确实是16位,而数据存储器仅为8位。 有趣的是,Atmel在开始时指出,这些是8位CPU。 与其他8位产品(如8051或Rabbit)相比,这使它们看起来非常具有竞争力。 由于16位程序数据路径,AVR在基准测试中表现非常出色。 后来,当8位听起来有点过时时,Atmel决定将它们称为8/16位CPU。 BitThe 8-bit AVR family is based on a (modified) ...