How to replace specified word of the Latin in other specified word using javascript?
I want to replace some word with another over javascript.
I find some code which I tried:
<script>
$string = str_replace(
array('š', 'č', 'đ', 'ć', 'ž'),
array('s', 'c', 'dj', 'c', 'z'),
$string);
</script>
but I don't know coding and when I put this on the website I got the error in console:
Uncaught ReferenceError: $ is not defined
javascript html
add a comment |
I want to replace some word with another over javascript.
I find some code which I tried:
<script>
$string = str_replace(
array('š', 'č', 'đ', 'ć', 'ž'),
array('s', 'c', 'dj', 'c', 'z'),
$string);
</script>
but I don't know coding and when I put this on the website I got the error in console:
Uncaught ReferenceError: $ is not defined
javascript html
you are getting this error because u have not loaded the jquery
– Amir shah
Dec 31 '18 at 19:16
2
^^^ Alsostr_replace
is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue
– Taplar
Dec 31 '18 at 19:17
use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");
– Amir shah
Dec 31 '18 at 19:20
Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)
– Mikkel
Dec 31 '18 at 22:54
add a comment |
I want to replace some word with another over javascript.
I find some code which I tried:
<script>
$string = str_replace(
array('š', 'č', 'đ', 'ć', 'ž'),
array('s', 'c', 'dj', 'c', 'z'),
$string);
</script>
but I don't know coding and when I put this on the website I got the error in console:
Uncaught ReferenceError: $ is not defined
javascript html
I want to replace some word with another over javascript.
I find some code which I tried:
<script>
$string = str_replace(
array('š', 'č', 'đ', 'ć', 'ž'),
array('s', 'c', 'dj', 'c', 'z'),
$string);
</script>
but I don't know coding and when I put this on the website I got the error in console:
Uncaught ReferenceError: $ is not defined
javascript html
javascript html
edited Jan 1 at 12:53
user5377037
7,430122661
7,430122661
asked Dec 31 '18 at 19:14
MarkMark
55
55
you are getting this error because u have not loaded the jquery
– Amir shah
Dec 31 '18 at 19:16
2
^^^ Alsostr_replace
is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue
– Taplar
Dec 31 '18 at 19:17
use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");
– Amir shah
Dec 31 '18 at 19:20
Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)
– Mikkel
Dec 31 '18 at 22:54
add a comment |
you are getting this error because u have not loaded the jquery
– Amir shah
Dec 31 '18 at 19:16
2
^^^ Alsostr_replace
is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue
– Taplar
Dec 31 '18 at 19:17
use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");
– Amir shah
Dec 31 '18 at 19:20
Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)
– Mikkel
Dec 31 '18 at 22:54
you are getting this error because u have not loaded the jquery
– Amir shah
Dec 31 '18 at 19:16
you are getting this error because u have not loaded the jquery
– Amir shah
Dec 31 '18 at 19:16
2
2
^^^ Also
str_replace
is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue– Taplar
Dec 31 '18 at 19:17
^^^ Also
str_replace
is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue– Taplar
Dec 31 '18 at 19:17
use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");
– Amir shah
Dec 31 '18 at 19:20
use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");
– Amir shah
Dec 31 '18 at 19:20
Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)
– Mikkel
Dec 31 '18 at 22:54
Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)
– Mikkel
Dec 31 '18 at 22:54
add a comment |
3 Answers
3
active
oldest
votes
you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
Now i get this error Uncaught ReferenceError: jQuery is not defined?
– Mark
Dec 31 '18 at 19:20
are you using the code without the <script> tag?
– Amir shah
Dec 31 '18 at 19:22
no, i put the <script> tag
– Mark
Dec 31 '18 at 19:23
use without the <script> tag.
– Amir shah
Dec 31 '18 at 19:28
add a comment |
codes you use in php code
<?php
$text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
$search = array('š', 'č', 'đ', 'ć', 'ž');
$replace = array('s', 'c', 'dj', 'c', 'z');
$string = str_replace($search, $replace, $text);
echo $string;
?>
he is asking for the jquery or javascript code to be placed in the console not for the php code.
– Amir shah
Dec 31 '18 at 19:36
add a comment |
var str = 'ščđ';
var mapObj = {
š:"s",
đ:"dj",
č:"c"
};
str = str.replace(/š|đ|č/gi, function(matched){
return mapObj[matched];
});
console.log(str);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53990729%2fhow-to-replace-specified-word-of-the-latin-in-other-specified-word-using-javascr%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
Now i get this error Uncaught ReferenceError: jQuery is not defined?
– Mark
Dec 31 '18 at 19:20
are you using the code without the <script> tag?
– Amir shah
Dec 31 '18 at 19:22
no, i put the <script> tag
– Mark
Dec 31 '18 at 19:23
use without the <script> tag.
– Amir shah
Dec 31 '18 at 19:28
add a comment |
you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
Now i get this error Uncaught ReferenceError: jQuery is not defined?
– Mark
Dec 31 '18 at 19:20
are you using the code without the <script> tag?
– Amir shah
Dec 31 '18 at 19:22
no, i put the <script> tag
– Mark
Dec 31 '18 at 19:23
use without the <script> tag.
– Amir shah
Dec 31 '18 at 19:28
add a comment |
you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
you are getting this error because u have not loaded the jquery To tackle this situation open the below link copy the code and paste it into your console.
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
answered Dec 31 '18 at 19:17


Amir shahAmir shah
1066
1066
Now i get this error Uncaught ReferenceError: jQuery is not defined?
– Mark
Dec 31 '18 at 19:20
are you using the code without the <script> tag?
– Amir shah
Dec 31 '18 at 19:22
no, i put the <script> tag
– Mark
Dec 31 '18 at 19:23
use without the <script> tag.
– Amir shah
Dec 31 '18 at 19:28
add a comment |
Now i get this error Uncaught ReferenceError: jQuery is not defined?
– Mark
Dec 31 '18 at 19:20
are you using the code without the <script> tag?
– Amir shah
Dec 31 '18 at 19:22
no, i put the <script> tag
– Mark
Dec 31 '18 at 19:23
use without the <script> tag.
– Amir shah
Dec 31 '18 at 19:28
Now i get this error Uncaught ReferenceError: jQuery is not defined?
– Mark
Dec 31 '18 at 19:20
Now i get this error Uncaught ReferenceError: jQuery is not defined?
– Mark
Dec 31 '18 at 19:20
are you using the code without the <script> tag?
– Amir shah
Dec 31 '18 at 19:22
are you using the code without the <script> tag?
– Amir shah
Dec 31 '18 at 19:22
no, i put the <script> tag
– Mark
Dec 31 '18 at 19:23
no, i put the <script> tag
– Mark
Dec 31 '18 at 19:23
use without the <script> tag.
– Amir shah
Dec 31 '18 at 19:28
use without the <script> tag.
– Amir shah
Dec 31 '18 at 19:28
add a comment |
codes you use in php code
<?php
$text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
$search = array('š', 'č', 'đ', 'ć', 'ž');
$replace = array('s', 'c', 'dj', 'c', 'z');
$string = str_replace($search, $replace, $text);
echo $string;
?>
he is asking for the jquery or javascript code to be placed in the console not for the php code.
– Amir shah
Dec 31 '18 at 19:36
add a comment |
codes you use in php code
<?php
$text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
$search = array('š', 'č', 'đ', 'ć', 'ž');
$replace = array('s', 'c', 'dj', 'c', 'z');
$string = str_replace($search, $replace, $text);
echo $string;
?>
he is asking for the jquery or javascript code to be placed in the console not for the php code.
– Amir shah
Dec 31 '18 at 19:36
add a comment |
codes you use in php code
<?php
$text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
$search = array('š', 'č', 'đ', 'ć', 'ž');
$replace = array('s', 'c', 'dj', 'c', 'z');
$string = str_replace($search, $replace, $text);
echo $string;
?>
codes you use in php code
<?php
$text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
$search = array('š', 'č', 'đ', 'ć', 'ž');
$replace = array('s', 'c', 'dj', 'c', 'z');
$string = str_replace($search, $replace, $text);
echo $string;
?>
<?php
$text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
$search = array('š', 'č', 'đ', 'ć', 'ž');
$replace = array('s', 'c', 'dj', 'c', 'z');
$string = str_replace($search, $replace, $text);
echo $string;
?>
<?php
$text = "99skdlsakd sakdlşsakşđđđd klşsaćkd lşds asldklş sadw";
$search = array('š', 'č', 'đ', 'ć', 'ž');
$replace = array('s', 'c', 'dj', 'c', 'z');
$string = str_replace($search, $replace, $text);
echo $string;
?>
answered Dec 31 '18 at 19:31
Doğan KılınçDoğan Kılınç
1
1
he is asking for the jquery or javascript code to be placed in the console not for the php code.
– Amir shah
Dec 31 '18 at 19:36
add a comment |
he is asking for the jquery or javascript code to be placed in the console not for the php code.
– Amir shah
Dec 31 '18 at 19:36
he is asking for the jquery or javascript code to be placed in the console not for the php code.
– Amir shah
Dec 31 '18 at 19:36
he is asking for the jquery or javascript code to be placed in the console not for the php code.
– Amir shah
Dec 31 '18 at 19:36
add a comment |
var str = 'ščđ';
var mapObj = {
š:"s",
đ:"dj",
č:"c"
};
str = str.replace(/š|đ|č/gi, function(matched){
return mapObj[matched];
});
console.log(str);
add a comment |
var str = 'ščđ';
var mapObj = {
š:"s",
đ:"dj",
č:"c"
};
str = str.replace(/š|đ|č/gi, function(matched){
return mapObj[matched];
});
console.log(str);
add a comment |
var str = 'ščđ';
var mapObj = {
š:"s",
đ:"dj",
č:"c"
};
str = str.replace(/š|đ|č/gi, function(matched){
return mapObj[matched];
});
console.log(str);
var str = 'ščđ';
var mapObj = {
š:"s",
đ:"dj",
č:"c"
};
str = str.replace(/š|đ|č/gi, function(matched){
return mapObj[matched];
});
console.log(str);
var str = 'ščđ';
var mapObj = {
š:"s",
đ:"dj",
č:"c"
};
str = str.replace(/š|đ|č/gi, function(matched){
return mapObj[matched];
});
console.log(str);
var str = 'ščđ';
var mapObj = {
š:"s",
đ:"dj",
č:"c"
};
str = str.replace(/š|đ|č/gi, function(matched){
return mapObj[matched];
});
console.log(str);
answered Dec 31 '18 at 19:56
JoshJosh
7019
7019
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53990729%2fhow-to-replace-specified-word-of-the-latin-in-other-specified-word-using-javascr%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you are getting this error because u have not loaded the jquery
– Amir shah
Dec 31 '18 at 19:16
2
^^^ Also
str_replace
is not a native javascript method. There is a php method by that name. So unless you have a definitiion for that method yourself, that's also an issue– Taplar
Dec 31 '18 at 19:17
use this function to replace the strings var str = "Visit Microsoft!"; var res = str.replace("Microsoft", "W3Schools");
– Amir shah
Dec 31 '18 at 19:20
Welcome to Stack Overflow. It sounds like you have a bit of learning ahead of you. There are plenty of resources out there such as Free Code Camp (which I recommend if you are serious about learning to code)
– Mikkel
Dec 31 '18 at 22:54