i am very newbie, so much confused to ask you for help me to add a new button to a webpage via UserScript
i tried several time but all my attempted failed, here is my button
<center> <button id="iabcc4f6ccb66734d26a4c190c889867d061" data-snip-rule="105" style="display: block;"> Continue </button></center>
would you mind to help me
i try to do it i just add this but can not handle the button
let btn = document.createElement("button"); btn.innerHTML = "Continue "; document.body.appendChild(btn);
Related
I was wondering if it was possible to use cookies in JavaScript to close a popup for cookie usage.
Is there any way to do it?
The code below sticks both of the pieces of code together as one entity, so it deletes both parts, while only trying to delete the popup part of it. I need to keep the <div id="e">© 2022 dont worry</div> part. Is there also a way to fix both issues at the same time or is that not possible?
My code:
<div id="sticky" class="alert-cookies">By using this search engine, you accept our use of cookies.Information
<href style="width: 100%">
<input id='btn' type="submit" onclick = "deleter()" value='OK'>
<script>
function deleter() {
document.cookie = true;
var btn = document.getElementById('btn');
btn.onclick = function () {
document.getElementById('sticky').remove();
this.remove();
};;
}
<div class="after footer_side1_wrapper">
<div id="e">© 2022 dont worry</div>
</div>
I am very new to web design and I am trying to get my javascript function and jquery to work. i have been trying to figure this out for a few days. with the function, I cant see why it wont work:
this is in my js file
function myFunction() {
document.getElementById("sign").innerHTML=
"Thank you for signing up!";,
document.getElementById("sign").innerHTML=
"I look forward to speaking with you soon";
}
this is in my html file
<button onclick="myFunction()">Sign Up</button>
<p id="sign"></p>
Here is the jQuery:
$("div:hidden:first").fadeIn(1000).delay(4000).slideUp(1000);
Have I written something wrong? Neither of these react.
I don't know exactly what's broken with your code,
wrapping the script tag in the bottom of your body should make all work well.
HTML:
<button onclick="myFunction()">Sign Up</button>
<div>
<p id="sign"></p>
</div>
JavaScript + jQuery:
var myFunction = function() {
let message = document.querySelector("#sign")
message.innerHTML = "Thank you for signing up!";
$("div:hidden").fadeIn(1000).delay(4000).slideUp(1000);
}
Is that what you wanted to achieve?
To make the message change, I think you have to use setTimeout so it changes/adds after few seconds...
This question is more a logic or best practice question than a technical one.
I have a form creator/render where certain admin users can design a form, and other general users can then use these already created a defined forms to request stuff.
On the general edit section of the form designer, user can move a component up, down, edit or delete it. For the deletion, I am looking for getting confirmation before actual deletion, so the way I could make it works is pretty much like this:
When the user click the delete button, a hidden html is displayed that request confirmation
$scope.clickDeleteButton = function ( index ) {
// log only for reference. Need to be removed
console.log('Delete button pressed');
deletion = true;
};
because var deletion is true this is confirmation is displayed
<div ng-show="confirmDeletion()" class="alert alert-danger" role="alert">
Please confirm that you want to delete the component
<button class="btn btn-sm btn-default pull-right" ng-click="deletionConfirmed($parent.$index)">Confirm</button>
<button class="btn btn-sm btn-default pull-right" ng-click="deletionCancelled()">Cancel</button>
</div>
And when the confirmation requested is accepted, then I process the deletion.
$scope.deletionConfirmed = function ( index ) {
//call deletion method in currentForm
console.log('Delete item with index: ', index);
FormServ.currentFormData.deleteItem(index);
};
This do the trick, but I dont feel it right. How is it done in real projects? Remember, I am already working on a modal so as far as I understand you cannot open a second modal.
Only for JS testing purposes: I need to go this this webpage and click Create new user as soon as the page loads . How can I do this ??
The first step is probably
<button onclick="location.href = 'http://jqueryui.com/dialog/#modal-form';" id="myButton" >Go to modal form</button>
Now what should I do ? Maybe there is a way to preload the target page and click on the create new user using JQuery ?
You can send parameters to control the logic.
I am a newbie to javascript and am currently building a website with a form that navigates users to a different page if they enter the correct code into a form and press the 'Submit' button.
Currently users have to click the 'Submit' button on the page in order for it to work — they can't use the 'Go' button on virtual keyboard on devices like tablets or iPhones at the moment. I want to fix the site so that users can also use the 'Go' button on their tablets and smartphones as an alternative to having to click the 'Submit' button'.
My code:
The button:
<button class="btn btn-info btn-large span12" id="joe_btn" onclick="onSubmit()" touchstart="onSubmit()">Submit</button>
The Javascript that runs it:
<script type="text/javascript">
function onSubmit() {
if (document.getElementById('password').value == '03010213') {window.location.href = 'map.html'; }
else{ alert('Please check your passcode and try again');}
}
</script>
How do I fix the code so that users can use the 'Go' button on their tablets and smartphones and it works as well?
Any feedback would be gratefully recieved! Please note, I am a complete beginner with Javascript, so please show the exact corrected code in your answers that I would need to use.
Many thanks,
Joe
I believe that in order for the Go button to show up, you need an input type="submit" on the page. On click of that button, run your function and return false. An actual form submit will not go through, as your script will take you to a different URL. Note that the inputs need to be part of a form as shown in the answer and in the fiddle. Here is a JSFiddle showing it working: http://jsfiddle.net/3TG6w/3/embedded/result - browse to this on your mobile device.
<form method="post" action="home.html">
<input type="password" id="password"/>
<input type="submit" class="btn btn-info btn-large span12" id="joe_btn" onclick="onSubmit(); return false;" touchstart="onSubmit(); return false;" value="Submit" />
</form>
<script type="text/javascript">
function onSubmit() {
if (document.getElementById('password').value == '03010213') {window.location.href = 'map.html';
}
else{
alert('Please check your passcode and try again');
}
}
</script>