Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Is there a way to use the following code:
$(document).ready(function () {
$('sd').hover(function() {
$(this).addClass('a');
}, function() {
$(this).removeClass('a');
});
});
without including the jquery file in my code? For example, is there a way to do exactly the same thing with pure javascript?
Sure, modified from this answer: Change an element's class with JavaScript
window.onload = function() {
var elements = document.getElementsByTagName('sd');
for (var i in elements) {
if (!elements.hasOwnProperty(i)) continue;
elements[i].addEventListener( 'mouseover', function() {
this.className += 'a';
}
elements[i].addEventListener( 'mouseout', function() {
this.className = this.className.replace( /(?:^|\s)a(?!\S)/g , '' );
}
}
}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
my question is very short want to this :
$(document).on('click', '.ee', function(){
$('.b').val("#Model.Result.GoingDate.AddDays(-1).ToString()");
#{Model.Result.GoingDate = Model.Result.GoingDate.AddDays(-1); }
});
but it's not working
is there any other way to that?
I know I can use javascript date
but don't know how
you cant do that with razor instead
use this method I kind of know what you need
you want to go to next day and update your text in HTML
$(document).on('click', '.ee', function () {
var currentDate = $('.txt-date').val();
var gdate = new Date(currentDate);
gdate.setDate(gdate.getDate() + 1);
$('.b').val(goingDate.toISOString().substring(0, 10));
});
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 6 years ago.
Improve this question
Well, the title of question look like easy, and the solution is:
$('.weatherCity').each(function () {
if ($(this).text() == 'LONDON') {
$(this).text('London Weather');
}
});
but I working on Yahoo! Weather Plugin and want to change city name, it's not iframe and we allow to change style and etc.. but look like it won't let change any text in this plugin. I thought browser read my code then yahoo get the weathers then I used promise().done() but nothing changed.
jsFiddle
Thanks in advance
-jiff
As a work around for this problem, you can use like this,
var interval = setInterval(function() {
if ($('.weatherCity').length) {
$('.weatherCity').each(function() {
if ($(this).text().trim() == 'London') {
$(this).text('London Weather');
}
});
clearInterval(interval);
}
}, 100);
Fiddle
Constantly checks for the element using setInterval and stop checking once it is found.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a record in the database like: <script src="here is link"></script>.
It's regexp for convert slash to special HTML char: string.replace(/\<\/script\>/g, '</script>');
Then I output it to the page.
It's result after output:
<script src="http://code.jquery.com/jquery-latest.min.js">
</script>
</script>
Why outputs HTML char? I need convert it again with regexp?
Use these JavaScript functions:
function decodeHTMLEntities(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
}
return buf.join('');
};
alert(decodeHTMLEntities('</script>'))
DEMO http://jsfiddle.net/tuga/6pXmn/3/
SRC https://gist.github.com/CatTail/4174511
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Can anyone explain what is meaning of this Regular Expression?
/^(https?):\/\/(www\.)?[a-zA-Z0-9\-\.]+\.[a-zA-Z0-9]{2,3}[a-zA-Z0-9\-\#\.\/\?]*$/
Finally I have founded my solution:
function validateURL(url)
{
var re = /^(https?):\/\/(www\.)?[a-z0-9\-\.]+\.[[a-z0-9\-\.\/]{2,}]*$/;
if (!re.test(url))
{
return false;
}
else
{
return true;
}
}
this function return true if your url contain these:
part 1. https or http
part 2. www or not (means optional).
Below image exploring in more depth.
I am wrong?
I've tried the following and works fine for me.
var url = "https://www.xyz.xe";
function validateURL(url)
{
var urlregex = new RegExp("^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*#)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");
return urlregex.test(url);
}
validateURL(url);
Returs false when url="https://www.xyz.x" and true when url="https://www.xyz.xe"
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i have this issue when im trying to upload a form in ie: Object doesn't support property or method 'ajaxSubmit' Here is my code:
function Upload() {
ShowWait();
uploadCompleted = false;
$(document.forms[0]).ajaxSubmit({ success: PostUploadProcess });
intervalHandler = setInterval(function () {
var responseText = $("iframe").contents().find("body").html();
if (responseText)
PostUploadProcess(responseText);
}, 1000);
return false;
}
Can anyone help me?
http://malsup.com/jquery/form/
needs to be separately included. its not part of jquery core.