我有一个简单的输入框
<input type="text" name="name">
提交name值的按钮代码是
<script
src="my_url"
data-name=" value that user puts should come here "
data-buttontext="Add Name">
</script>
我希望只要用户将值放入输入中,就应该将其分配给data-name
任何人都可以告诉我们该怎么做
答案 0 :(得分:0)
将数据名称分配给脚本中的文本值:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
static NSString *cellIdentifier = @"cellWithTextField";
UserDetailCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell = [tableView dequeueReusableCellWithIdentifier:@"cellWithTextField"];
cell.userDetailLabel.text = [userDetail objectAtIndex:indexPath.row];
return cell;
}
else if (indexPath.section == 1) {
DetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
cell = [tableView dequeueReusableCellWithIdentifier:@"cellWithLabel"];
cell.userInfoLabel.text = [userInfo objectAtIndex:indexPath.row];
return cell;
}
else if (indexPath.section == 2)
{
static NSString *cellIdentifier2 = @"cell";
static NSString *cellIdentifier1 = @"cellWithLabel";
NewControllerCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.detailLabel.text = [detail objectAtIndex:indexPath.row];
return cell;
}
}
答案 1 :(得分:0)
$("input[name='name']").keyup(function(e){
var currval = $(this).val();
$("button").data("name",currval);
});
答案 2 :(得分:0)
此脚本应该有帮助
ipython3 notebook my_notebook.ipynb
答案 3 :(得分:0)
$(document).on('keyup','[name=name]',function(ev){
var value = $(this).val();
$('[src=my_url]').attr('data-name', value);
console.log($('[src=my_url]').attr('data-name'));
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="my_url" data-name=" value that user puts should come here " data-buttontext="Add Name">
</script>
<input type="text" name="name">
答案 4 :(得分:0)
将Id
属性设置为您的脚本和输入标记,以便您在输入中绑定keyup
事件,并找到正确的脚本标记以进行正确更新。
$('#myInput').on('keyup',function(e){
$('#myScript').data('name', $(this).val());
//for test
alert($('#myScript').data('name'));
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script id="myScript" src="my_url" data-name=" value that user puts should come here " data-buttontext="Add Name">
</script>
<input id="myInput" type="text" name="name">
&#13;