Size: a a a

2020 January 22

V

Vladislav in JS Liberty
Так что, this.id или event.target.id будет правильным ответом на мой вопрос? Что будет более правильно?
источник

V

Vladislav in JS Liberty
Всем привет. Как получить id данного инпута в функции которая находится в onclick?
<input id="some_id" onclick="func()"
      type="button"  value="some_value">
источник

nn

nolanson no in JS Liberty
Vladislav
Всем привет. Как получить id данного инпута в функции которая находится в onclick?
<input id="some_id" onclick="func()"
      type="button"  value="some_value">
func(this.id) function func(id) { console.log(id); }
источник

V

Vladislav in JS Liberty
nolanson no
func(this.id) function func(id) { console.log(id); }
А почему не event.target.id?
источник

DE

Denis Efremov in JS Liberty
onclick="func"

function func (e) {
 console.log(e.target.id)
}
источник

V

Vladislav in JS Liberty
Так как же будет сделать правильнее?
источник

nn

nolanson no in JS Liberty
function func(id) {
   console.log(id);
}
undefined
local-ntp.html:1 Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'strict-dynamic' 'sha256-1+GSDjMMklBjZY0QiWq+tGupCvajw4Xbn46ect2mZgM=' 'sha256-62BI1h5Lu39149gGKEGjqxgsHZu2JNRhl4obe1llONU=' 'sha256-lxZQy/p64jMr2Zq97RuobZ9Oye/OePv2Uyq+E4U7r40=' 'sha256-HqdPsO6hNmT/mfSeGdcX3eEGrZVva7AKD2Z2+1ujCZ8=' 'sha256-jf3gjwPzf/tDQVQ7SPvYlpGeWGFHxBOyH0UQnSpnpi4=' 'sha256-IEF9PjeyU0vsr61C8cm3JQOerOYWdBsaGddCSPp6tZs=' 'sha256-RIDhH5uF+ciLoS6AP6ZkoxuwQyczkrTetThxXwVwFJI=' 'sha256-rFAAhGzRoYQp3O8/cZLtC+AJ9MUWN0UEb9rYgpfkDLs='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.

function func(e) {
   console.log(e.target.id);
}
undefined
local-ntp.html:1 Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'strict-dynamic' 'sha256-1+GSDjMMklBjZY0QiWq+tGupCvajw4Xbn46ect2mZgM=' 'sha256-62BI1h5Lu39149gGKEGjqxgsHZu2JNRhl4obe1llONU=' 'sha256-lxZQy/p64jMr2Zq97RuobZ9Oye/OePv2Uyq+E4U7r40=' 'sha256-HqdPsO6hNmT/mfSeGdcX3eEGrZVva7AKD2Z2+1ujCZ8=' 'sha256-jf3gjwPzf/tDQVQ7SPvYlpGeWGFHxBOyH0UQnSpnpi4=' 'sha256-IEF9PjeyU0vsr61C8cm3JQOerOYWdBsaGddCSPp6tZs=' 'sha256-RIDhH5uF+ciLoS6AP6ZkoxuwQyczkrTetThxXwVwFJI=' 'sha256-rFAAhGzRoYQp3O8/cZLtC+AJ9MUWN0UEb9rYgpfkDLs='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.
источник

nn

nolanson no in JS Liberty
и так и так не работает
источник

DE

Denis Efremov in JS Liberty
А где ты проверяешь?
источник

nn

nolanson no in JS Liberty
на стартовой странице хрома)))
источник

DE

Denis Efremov in JS Liberty
В песочнице проверь
источник

nn

nolanson no in JS Liberty
тут то че не работает
источник

nn

nolanson no in JS Liberty
источник

DE

Denis Efremov in JS Liberty
Написано же че
источник

МВ

Михаил Васильев in JS Liberty
nolanson no
function func(id) {
   console.log(id);
}
undefined
local-ntp.html:1 Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'strict-dynamic' 'sha256-1+GSDjMMklBjZY0QiWq+tGupCvajw4Xbn46ect2mZgM=' 'sha256-62BI1h5Lu39149gGKEGjqxgsHZu2JNRhl4obe1llONU=' 'sha256-lxZQy/p64jMr2Zq97RuobZ9Oye/OePv2Uyq+E4U7r40=' 'sha256-HqdPsO6hNmT/mfSeGdcX3eEGrZVva7AKD2Z2+1ujCZ8=' 'sha256-jf3gjwPzf/tDQVQ7SPvYlpGeWGFHxBOyH0UQnSpnpi4=' 'sha256-IEF9PjeyU0vsr61C8cm3JQOerOYWdBsaGddCSPp6tZs=' 'sha256-RIDhH5uF+ciLoS6AP6ZkoxuwQyczkrTetThxXwVwFJI=' 'sha256-rFAAhGzRoYQp3O8/cZLtC+AJ9MUWN0UEb9rYgpfkDLs='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.

function func(e) {
   console.log(e.target.id);
}
undefined
local-ntp.html:1 Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'strict-dynamic' 'sha256-1+GSDjMMklBjZY0QiWq+tGupCvajw4Xbn46ect2mZgM=' 'sha256-62BI1h5Lu39149gGKEGjqxgsHZu2JNRhl4obe1llONU=' 'sha256-lxZQy/p64jMr2Zq97RuobZ9Oye/OePv2Uyq+E4U7r40=' 'sha256-HqdPsO6hNmT/mfSeGdcX3eEGrZVva7AKD2Z2+1ujCZ8=' 'sha256-jf3gjwPzf/tDQVQ7SPvYlpGeWGFHxBOyH0UQnSpnpi4=' 'sha256-IEF9PjeyU0vsr61C8cm3JQOerOYWdBsaGddCSPp6tZs=' 'sha256-RIDhH5uF+ciLoS6AP6ZkoxuwQyczkrTetThxXwVwFJI=' 'sha256-rFAAhGzRoYQp3O8/cZLtC+AJ9MUWN0UEb9rYgpfkDLs='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.
источник

nn

nolanson no in JS Liberty
document.write(<input type="text" id="test" onclick="func" />);
undefined
VM8266:1 Uncaught SyntaxError: Unexpected identifier
local-ntp.html:1 Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'strict-dynamic' 'sha256-1+GSDjMMklBjZY0QiWq+tGupCvajw4Xbn46ect2mZgM=' 'sha256-62BI1h5Lu39149gGKEGjqxgsHZu2JNRhl4obe1llONU=' 'sha256-lxZQy/p64jMr2Zq97RuobZ9Oye/OePv2Uyq+E4U7r40=' 'sha256-HqdPsO6hNmT/mfSeGdcX3eEGrZVva7AKD2Z2+1ujCZ8=' 'sha256-jf3gjwPzf/tDQVQ7SPvYlpGeWGFHxBOyH0UQnSpnpi4=' 'sha256-IEF9PjeyU0vsr61C8cm3JQOerOYWdBsaGddCSPp6tZs=' 'sha256-RIDhH5uF+ciLoS6AP6ZkoxuwQyczkrTetThxXwVwFJI=' 'sha256-rFAAhGzRoYQp3O8/cZLtC+AJ9MUWN0UEb9rYgpfkDLs='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.
источник

nn

nolanson no in JS Liberty
😊
источник

M

MultiFruit in JS Liberty
nolanson no
parameters. Do it like this:

<button id="1" onClick="reply_click(this.id)">B1</button> <button id="2" onClick="reply_click(this.id)">B2</button> <button id="3" onClick="reply_click(this.id)">B3</button> <script type="text/javascript"> function reply_click(clicked_id) { alert(clicked_id); } </script>
прикольно, не знал про this
источник

OM

Oleksii Musiienko in JS Liberty
как я могу експортнут компонент и коннект?
источник

OM

Oleksii Musiienko in JS Liberty
потому-что в консольке у меня андерфайнд
источник