gpt4 book ai didi

jquery - 检索 View 中选择选项的值

转载 作者:行者123 更新时间:2023-12-01 05:29:47 26 4
gpt4 key购买 nike

我的观点如下:

<%= select_tag(:option_id, options_for_select([
['Students', 1],
['Teachers', 2],
])) %>

如何在 View 本身中检索所选值?我想动态更改 <%= link_to %> 的值以此为基础。

这是我的部分 CoffeeScript :

jQuery ->
$('#import_type').change ->

现在如何更改 <%= link_to %> 的值?

最佳答案

你可以这样做:

jQuery ->
$('#import_type').change ->
if $('#import_type').val() == '1'
$('#link_to_id').attr("attribute", "value")

确保将 link_to_id 替换为实际 ID。

关于jquery - 检索 View 中选择选项的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38287019/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com