can I define border width. like
.box{
width:200px;
height:150px;
border-bottom:1px solid #000;
}
box width is 200px but i want border width in bottom only 100px.
Take the following example:
$.fn.foo = function() {
var $input = $('<input type="text"/>');
var $button_one = $('<button>One</button>');
var $button_two = $('<button>Two</button>');
$button_one.click(function(){
$input.val('hey');
});
$button_two.click(function(){
$input.replaceWith( $input.val('').clone( true ) );
});
this.append($input, $button_one, $button_two);
};
Check the demo: http://jsbin.com/ezexah/1/edit
Now click "one" and you should see "hey" in the input. Next click "two" and then click "one" again and it doesn't work. Even using the true option in clone to copy all events it still does not work. Any ideas?
That sounds pretty odd but i have this cod and i need to convert it to checkbox, with the same functionalities
<select onchange="document.getElementById('reasonDiv{$test->id}').style.display = '';
document.getElementById('reason{$test->id}').value = this.value;" name='reasonId{$test->id}' id='reasonId{$test->id}'>
<option value=''>Test</option>
{foreach item=test from=$testtmp.6}
<input type="checkbox" value='{include file='testen.tpl'
blog=$test1 member=$test2 contents=$test->contents replyId=$test->predefinedreplyid }' label='{$test->predefinedreplyid}'
{if $test->predefinedreplyid==$test1->declineId}selected="selected"{/if}>{$test->subject}</option>
{/foreach}
</select>
How can i do that? Thanks for help
This code takes 3 seconds on Chrome and 6s on Firefox.
If I write the code in Java and run it under Java 7.0 it takes only 10ms.
Chrome's JS engine is usually very fast. Why is it so slow here?
btw. this code is just for testing. I know it's not very practical way to write a fibonacci function
fib = function(n) {
if (n < 2) {
return n;
} else {
return fib(n - 1) + fib(n - 2);
}
};
console.log(fib(32));
I have a classified website, with pretty sophisticated searching, and I am about to implement a function where the last three queries is displayed for the user, so that the user can go back easier through the queries.
This because for each query the user has to provide a lot of input.
I have four questions for you:
I wonder, how can I save the actual query (SELECT * FROM etc etc)...?
Do I need to add some form of encryption to be on the safe side?
How will this affect performance? (I don't like the fact that cookies slow websites down)
Anything else to think about?
If you need more input, let me know...
Btw, the website is PHP based.
Thanks
I'm trying to calculate the width of the string based on the font style and size. The user will provide the string, the font style and the font size, and then after giving all the data the user will hit the submit button and the function will trigger. Basically this script works but only when the submit button is hit twice or the font is selected twice,. I mean if you selec DNBlock as a font, it will not work for first time, but the second time you hit submit, it will then work. I'm not sure where is the problem here, but when I used the default font style like Arial, times new roman etc it works perfectly fine. Any Idea on this? I suspected that the font style is not being rendered by the script or something. Correct me if I'm wrong. Thanks
//Repeat String
String.prototype.repeat = function( num )
{
return new Array( num + 1 ).join( this );
}
//Calculate the width of string
String.prototype.textWidth = function() {
var fntStyle = document.getElementById("fntStyle").value;
if(fntStyle == "1")
{
var fs = "DNBlock";
}
else if(fntStyle == "2")
{
var fs = "DNBlockDotted";
}
else if(fntStyle == "3")
{
var fs = "DNCursiveClassic";
}
else if(fntStyle == "4")
{
var fs = "DNCursiveDotted";
}
else if(fntStyle == "5")
{
var fs = "FoundationCursiveDots-Regul";
}
var f = document.getElementById("fntSize").value.concat('px ', fs),
o = $('<div>' + this + '</div>')
.css({'position': 'absolute', 'float': 'left', 'white-space': 'nowrap', 'visibility': 'hidden', 'font': f})
.appendTo($('body')),
w = o.width();
o.remove();
return w;
}
//Trigger the event
$("#handwriting_gen").submit(function () {
var rptNO = parseInt($('#rptNO').val());
$("[name='txtLine[]']").each(function(){
alert(this.value.repeat(rptNO).textWidth());
if(this.value.repeat(rptNO).textWidth() > 1000)
{
$(this).focus();
$(this).css({"background-color":"#f6d9d4"}).siblings('span.errorMsg').text('Text is too long.');
event.preventDefault();
}
});
});
I am grabbing data through a jQuery Ajax call, and displaying it on the page. I need to wait for both the DOM to load and for the Ajax call to complete before I can use the data to display it on the page. Can an Ajax call ever complete before the DOM has loaded? I'm just trying to determine where I need to put my method that will manipulate the DOM and use the data I'm getting back.
Hello all,
I have tags in a html list, here is an example of two tags.
<div class="tags">
<ul>
<li>
<a onclick="tag_search('tag1');" href="#">tag1
<span class="num-active">1</span></a>
</li>
<li>
<a onclick="tag_search('tag2');" href="#">tag2
<span class="num-active">1</span></a>
</li>
</ul>
</div>
I would like to write a function that I can pass a string to, that will match the strings in the a hyperlink i.e. "tag1" or "tag2", if there is a match then increment the number in the span, if not then add a new li.
The bit I am having trouble with is how do I search for a string in the div with class tags and then when I find a match identifying the element. I can't even do the first bit as I am use to using an ID or a Class.
I appreciate any help on this using JQuery
Thanks all
Code so far
function change_tag_count(item){
alert(item);//alerts the string test
$.fn.searchString = function(str) {
return this.filter('*:contains("' + item + '")');
};
if($('body').searchString(item).length){
var n = $('a').searchString(item).children().text();
n = parseInt(n) + 1;
$('a').searchString(item).children().text(n);
}else{
alert('here');//does not alert this when no li contains the word test
$("#all_tags ul").append('<a onclick="tag_search(\''+item+'\');" href="#">'+item+'<span class="num-active">1</span></a>');
}
}
I am facing an issue in my application user directly clicked on browser close [X] button. Browser can be IE, Chrome, Mozilla, Firefox and many more.
What I want to do :
1. as soon as User hits [X] button of browser, need to set there status as logged off in database for which we have a method in Login.aspx file which is within the masterpage.
2. We do not have any Logoff feature in the application
I will be thanlful if anyone suggest a solution to call the method which sets the user status as logged off from master page.
Thanks in advance.
In my JSP page I am using post method while submitting the page.
So once I go from Page 1 to page 2. In Page 2, If I press F5 I am getting alert as
"To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier."
I knew this question is a bit sarcastic but please give me an Idea.
I can't change my method from POST to GET because I need to send large amount of data.
Thanks in advance...
Edited:
In my Page1.JSP I call onClick function in that function I call action as "/page2servlet.do".
Now, In Java side I use Spring Framework. With MVC Object I return to page2.jsp.
So where do the response.sendRedirect Fit.
Hi,
I'm using the canvas feature of html5. I've got some images to draw on the canvas and I need to check that they have all loaded before I can use them.
I have declared them inside an array, I need a way of checking if they have all loaded at the same time but I am not sure how to do this.
Here is my code:
var color = new Array();
color[0] = new Image();
color[0].src = "green.png";
color[1] = new Image();
color[1].src = "blue.png";
Currently to check if the images have loaded, I would have to do it one by one like so:
color[0].onload = function(){
//code here
}
color[1].onload = function(){
//code here
}
If I had a lot more images, Which I will later in in development, This would be a really inefficient way of checking them all.
How would I check them all at the same time?
I have a stack of <div> elements that show a name. I'd like to include a + link off to the side that, when clicked, expands the <div> and adds more detailed information (from a RoR controller).
After poking around on the net, I found link_to_remote and related RoR stuff, but I can't seem to get the right combination to work together. Can someone point me to a tutorial or show what the controller and view interaction should look like?
Thanks!
I have created a html page in php and upon submission i validates that page using PHP. After validating i want to show an alert msg to show its status like showing any greeting or request for re-enter.
I have dont validation. Now i m using
header( 'Location: http://localhost/assignment/WebForm.htm' ) ;
to redirect user to same page but with a alert msg at page load or something like that. What I need to do ?
I cannot figure out what I did or did not do here syntactically to cause this error. I don't see what's missing:
function ShowWaitMessage(button)
{
var isValid;
if (buttonSelected())
{
showWaitMessage(button, "showMessage1");
isValid = true;
}
else
{
Page_ClientValidate();
if (Page_IsValid)
{
showWaitMessage(button, "showMessage2");
isValid = true;
}
}
return isValid;
}
i want move up the object, delay 1000ms , then hide it,
i get the code:
$("#test").animate({"top":"-=80px"},1500)
.animate({"top":"-=0px"},1000)
.animate({"opacity":"0"},500);
i use ".animate({"top":"-=0px"},1000)" to implement delay, it's not good.
i want:
$("#test").animate({"top":"-=80px"},1500)
.sleep(1000)
.animate({"opacity":"0"},500);
any idea? thanks! :)
{"paging": {"pageNum":2,"action":"Next","type":"","availableCacheName":"getAllFunds","selectedCacheName":"","showFrom":101,"showTo":200,"totalRec":289,"pageSize":100},
"Data":[{"sourceCodeId":0,"radio_fund":"individua
l","availableFunds":[],"fundId":288,"searchName":[],"fundName":"Asian Equity Fund A Class Income","srcFundGrpId":"PGI","firstElement":0,"las
tElement":0,"totalElements":0,"pageList":[],"standardExtract":true}]
I have json file with above format with two fileds,one paging and one is Data array.
I able to retrieve values of paging,but i am not able to retrieve the values of data array with .each function of jquery.
Any suggestions or inputs really appreciated.
I am working on Ruby on Rails application, with Prototype.
I want to display a loading div automatically with every ajax request and hide it on completion, without writing code for every ajax request in my application.
Is there anyway to do this.
<div id="loader">Loading...</div>
Hello,
I am trying to get the Treemap plugin (http://www.jquery.info/spip.php?article40) working with jQuery v1.3.x. The plugin works with jQuery v1.1 and v1.2 but for some reason it fails with the v1.3 base.
This is the browser error "Error: uncaught exception: Syntax error, unrecognized expression: "
Does anyone know changes occurred between JQuery v1.2 and v1.3 that could cause this?
Cheers,
D
I want to add an event handler to some dynamically added elements. I simplified my problem into the basic code below. I am using the new JQuery 1.7 on feature to say "hey for all labels in the CancelSurvey id element call this notify function when they are clicked."
function notify(event) {
console.log(event.data.name);
}
$('#CancelSurvey').on('click', 'label', { name: $(this).attr("id") }, notify);
I want to pass the id of the label as parameter "name". When I try to alert this it is undefined (they are defined in the html created). I believe that using the $(this) is not referencing the label selector in this case. It actually seems to be referencing the document itself. Any ideas on how to accomplish this?
I'm trying to wrap a div around an element (my 'template' div) by using jQuery's before() and after(). When I try to insert a closing after the selected element, it actually gets placed before the target.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Div Wrap</title>
<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script>
$('document').ready(function() {
var beforestr = "<div id=\"wrap\"><div id=\"header\">Top</div><div id=\"page\">";
var afterstr = "</div><div id=\"footer\">Bottom</div></div>";
$('#template').before(beforestr);
$('#template').after(afterstr);
});
</script>
</head>
<body>
<div id="template">
<h1>Page Title</h1>
<p>Pellentesque habitant morbi tristique senectus
et netus et malesuada fames ac turpis egestas. Mauris
placerat eleifend leo. Quisque sit amet est et sapien
ullamcorper pharetra.
<script>document.write('This script should still work and might contain variables. Please don\'t recommend concatenation.');</script>
Donec non enim in turpis pulvinar facilisis.</p>
</div>
</body>
</html>
The result is:
<div id="wrap">
<div id="header">Top</div>
<div id="page">
</div>
</div>
<div id="template">
<h1>Page Title</h1>
<p>Pellentesque habitant morbi tristique senectus
et netus et malesuada fames ac turpis egestas. Mauris
placerat eleifend leo. Quisque sit amet est et sapien
ullamcorper pharetra.
This script should still work and might contain variables. Please don't recommend concatenation.
Donec non enim in turpis pulvinar facilisis.</p>
</div>
<div id="footer">Bottom</div>
Why are my closing wrap and page divs getting placed before the target, when I'm trying to place them after() ? Is there an alternative way to accomplish this (keeping in mind I may need to call script functions within the template div)?
As I'm sure you're aware, best practices aren't what I'm going for here.
I need to check the checked property of a checkbox and perform an action based on the checked property using jQuery.
For example, if the age checkbox is checked, then I need to show a textbox to enter age, else hide the textbox.
But the following code returns false by default:
if($('#isAgeSelected').attr('checked')) {
$("#txtAge").show();
} else {
$("#txtAge").hide();
}
How do I successfully query the checked property?
Where I can find a complete list of all jQuery supported events (like click, mouseup etc) with some explanations when they are triggered? I am looking for those that can be binded:
$('#foo').bind('click', handler);
For example I just found out by accident that there is paste event but I can't find any references to it anywhere in their docs. What else is there?