如何在onclick函数html中传递字符串 [英] how to pass string in onclick function html

查看:58
本文介绍了如何在onclick函数html中传递字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了一个老问题,在那里他们将js中的值传递给js.但是我想将字符串从html传递给javascript.但它给出了

I tried with old question, there they passing the value in js to js.But I would like to pass string from html to javascript. but it gives

未捕获的参考错误

Uncaught reference error

我的 html

<a href="#" onclick="test(TEST123)">

和我的 javascript

function test(p){
   alert(p)
}

如何传递字符串>

推荐答案

<a href="#" onclick="test('TEST123')">

在您的js函数中仅保留字符串参数

just wite string parameter in your js function

这篇关于如何在onclick函数html中传递字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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