<button type="button" onclick="method( document.getElementById("panelTxt").value )"></button>
Don't include the # in your ID of getElementById as suggested in comments.
Here is an unobtrusive way to get the value of the textarea after ANY button in the panel
document.querySelectorAll(".panel>button").forEach(function(but) {
but.addEventListener("click",function(e) {
e.preventDefault();
console.log(this.nextElementSibling.value);
});
});
<div id="panel1" class="panel">
<button id="c1">Click</button>
<textarea id="c2">value 1</textarea>
</div>
<div id="panel2" class="panel">
<button id="c3">Click</button>
<textarea id="c4">value 2</textarea>
</div>
First I suggest avoiding the use of inline-event onclick
and attach the event in your JS code using addEventListener()
, then it will be better to use nextElementSibling
property and get the content of the next field using value
:
document.getElementById('panelBtn').addEventListener('click', function() {
console.log(this.nextElementSibling.value);
})
<div id="Panel">
<button id="panelBtn" class="button">Click Me</button>
<textarea id="panelTxt" class="textarea">Insert text here</textarea>
</div>
I'm using Template.uploadFile.events({ 'change .set-file': function ( event, template ) { var file = event.currentTarget.files[0]; [...] } }); when uploading a file. I want to read ...
I'm using Template.uploadFile.events({ 'change .set-file': function ( event, template ) { var file = event.currentTarget.files[0]; [...] } }); when uploading a file. I want to read ...
I have a screen in my app that has a "in between" content. This content is too long for the Iphone 5-8, but just one screen for the Iphone 8S-XS Max. To fix it, I've put on a simple ScrollView, ...
I have a screen in my app that has a "in between" content. This content is too long for the Iphone 5-8, but just one screen for the Iphone 8S-XS Max. To fix it, I've put on a simple ScrollView, ...
I am working on an application that uses angular js UI grid. But as and when I keep using my application, it keeps adding up to the memory without releasing the dom objects. I have created a sample ...
I am working on an application that uses angular js UI grid. But as and when I keep using my application, it keeps adding up to the memory without releasing the dom objects. I have created a sample ...
I need to transfer state of a component to its parent component, but I don't need to transfer all fields. What I currently do: submitHandler = (e) => { e.preventDefault(); const ...
I need to transfer state of a component to its parent component, but I don't need to transfer all fields. What I currently do: submitHandler = (e) => { e.preventDefault(); const ...