dynamicdrive.comのShowHintスクリプトを使用して、Webサイトにフォームエラーを表示しようとしています。
現在、エラーは次のように表示されます
<span class="error">Error Message</span>
入力の1つにエラーがある場合。
代わりにshowhintスクリプトを使用してこのエラーを表示したいので、エラーのあるすべてのページを置き換えて編集する必要があります
<span class="error">Error Message</span>
と
<span class="error erroranchor" onmouseover="showhint('Error Message Here', this, event, '200px')"></span>
手動で。
しかし、私はここでエネルギーを節約しようとしています。これが、代わりにJQueryを使用することにした理由です。クエリを使用するのは初めてで、これが私の最初のコーディングループになります。論理的な観点から、JQueryは一番。これが私がこれまでに行ったことですが、何も機能していません。
<script type='text/javascript'>
//On document ready.. I'm not sure if it should be document ready or document load.
$(document).ready(function() {
//First i add the class "erroranchor" to <span class="error">
$(".error").addClass("erroranchor");
//Then i've tried to convert the onmouseover event to JQuery mouseover event.
$(".erroranchor").mouseover(showhint(){
//Here i try to get the "Error Message" from <span class="error">Error Message</span> so it can be displayed in the hint box.
var $errortext = $(this);
$errortext.text(),
this.event,
'200px'
});
});
</script>
次に、私が望むように完全に機能するCSSがあります。
.error {
text-indent: -99999px;
}
.erroranchor {
background: url(anchor.png);
}
上記のJavaScriptを改善していただければ幸いです(わかりやすくしてください)。