is it okay to write javascript code in angular [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Hi I have a general question is it okay to write JavaScript code in angular (in my case for dom manipulation)
Here is an example of what i would use.
Thanks in Advance.
document.querySelectorAll('div.links a').forEach(function(item) {
const tag = window.location.href.indexOf('content') > -1 ? 'hello' : 'hai';
const href = `${item.getAttribute('href')}${brand}`;
item.setAttribute('href', href);
});

You should access to dom elements using angular properties such as ElementRef/ViewChild like it says on the answer here:
Access to dom elements

Related

Is writing HTML values the same as writing Javascript into HTML? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
For my project I am not allowed to write any JavaScript into my HTML according to my teacher. That would mean that I am not allowed to write features like onClick in my HTML. I want to check a answer with the if statement by giving my buttons value's, but isn't that also seen as writing JavaScript into HTML?
I know the best thing to do would be contact my mentor, but I want to know your answer/opinion on this.
you can use JS function to get elements from the HTML such as document.getElementById or document.querySelector and bind them an event listener.
you can read more about on MDN

Came across a javascript code, which I can't read [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I came across this java script code and I don't know how I encode it. Here is a part of it:
var _0x6ah4=['a22uo1w=','a2VlcC1h2ZQ==','YMA0aG9y8XVlML==','Z3cCwgZGVmHBbG0ZQ==','Qk1OQ04=','enNHYAM=','P0ASTmI=','RkVPOE9=','Y2AQUEc=']
Can somebody tell me how to convert this into readable code?
var _0x6ah4=['a22uo1w=','a2VlcC1h2ZQ==','YMA0aG9y8XVlML==','Z3cCwgZGVmHBbG0ZQ==','Qk1OQ04=','enNHYAM=','P0ASTmI=','RkVPOE9=','Y2AQUEc=']
Its simple.
variable name _0x6ah4 ,
its an array containing 9 elements.
You can fetch the data using foreach, if you want.
var _0x6ah4=['a22uo1w=','a2VlcC1h2ZQ==','YMA0aG9y8XVlML==','Z3cCwgZGVmHBbG0ZQ==','Qk1OQ04=','enNHYAM=','P0ASTmI=','RkVPOE9=','Y2AQUEc='];
for (var line=1; line<_0x6ah4.length; line++) {
console.log(_0x6ah4[line]);
//if you need to decode , do it here
}

JavaScript version of this jQuery line [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am searching for a javascript alternative for the following code:
$('a[href*="vivo.sx/"]').attr('href')
I have never worked with javascript. This may be very simple for someone who's more experienced with javascript.
I've done a version that does it both way for comparison..
Please note I've used document.querySelector, not document.querySelectorAll, if you use the All variant, remember you need to loop the result.
console.log( $('a[href*="vivo.sx/"]').attr('href') );
console.log( document.querySelector('a[href*="vivo.sx/"]').href );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
one

Application to verify code in Javascript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I had found this page and I would like to know how this editor is working, in example:
Some task to write alert(); but If you write alert("lol"); then too is ok, and you can pass to next task,
How this editor is verifies the correctness? Any example? example can be realy simply
It simply runs your code with small JS tests to check if your code is correct.
Example :
Step 4 : Assign value "Gregg" to firstname. (var firstname = "Gregg")
It simply has to check if firstname has been assigned a value.

How do I use a var to access json object property [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
So here's a little test I'm doing to check if I'm grabbing all the thumbs from my object. Problem is projectName is coming up undefined. Whhhhaaa?
var projectName = $(this).attr("href");
console.log(worklist.work.projectName.thumbs.length);
If you need to access a property dynamically, use bracket-notation.
console.log(worklist.work[projectName].thumbs.length);
try
console.log(worklist.work[projectName].thumbs.length);

Categories

Resources