English 中文(简体)
How do I use the "highlight" jquery effect without temporarily hiding the background-image?
原标题:

I am trying to use the jquery ui "highlight" effect on an input html element with a background image set in the CSS (A search bar with a magnifying glass). During the "highlight" animation, however, the background image temporarily goes away and then appears once the highlight animation is over. I would like the image to remain throughout the animation. Any ideas?

HTML:

<input class="searchInput" id= searchInputWithMap  type="text" tabindex="100" name="searchStructures" />

CSS:

.searchInput {

 font-family:Trebuchet MS,Helvetica,sans-serif;
 background:transparent url(/images/search4.png) no-repeat scroll 8px 6px;
 height:22px;
 line-height:28px;
 padding-left:32px;
 padding-right:3px;
 padding-top:5px;
 padding-bottom:5px;
 margin:5px 0;
 border:1px solid #999999;
 font-size:130%;
 height: 32px; 
 width: 400px;
 vertical-align:center;
    color:#BBBBBB;

}
最佳回答

When highlight is called, the source sets the backgroundImage to none , and I don t know of a way to configure that. You can always create your own highlight effect and simply not remove the backgroundImage(I ve done this, just copy/paste the original and change one .css() call).

Another thing you can do, although it isn t as clean is:

$("#searchInputWithMap").click(function () {
    $(this).effect("highlight", {}, 3000);
    $(this).css( backgroundImage , url(/images/search4.png) );
 });

There will be a gap, but this will put the background image back in place right after the highlight animation has started.

问题回答

Add !important to your CSS, like this:

.searchInput { background-image:url(/images/search4.png) !important; }

Use with care.

I dug into the highlight code of JQuery UI, and I think line #4583 is your problem:

el.css({backgroundImage:  none , backgroundColor: color});

You could change your copy of this function to look more like this:

el.css({backgroundColor: color});

Can you add a transparent alpha channel to the highlight color? I m not really familiar with CSS, but that would seem like the place to check.

Otherwise, could you just replace the bg image with a version you made that appears highlighted and not highlight the box at all?





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签