jQueryで行を表示するgradientの背景色をリストする
-
16-10-2019 - |
質問
SharePoint 2007では、コンテンツタイプを使用してnewform.aspxを編集してjQueryで編集しました。新しいアイテムの外観をカスタマイズし、各コンテンツタイプにグラデーションカラーアイデンティティを追加しました。私もその見方を続けたいです。 「すべてのアイテム」ビューについては、スタイルとjQueryスクリプトをコーディングしたコンテンツエディターWebパーツを追加しました。ビューにグラデーションの色を表示できるようになりたいのですが、Firefoxで達成していますが、IE8は抵抗しているようです。
コンテンツエディターのWebパートには、Forfoxで動作するがIE8では機能しないコードがあります。問題は、IE8がjQueryステートメントを処理しないということです。 $ text.parent();.
質問:obj.parent()を使用せずに親にクラスを追加する方法を知っている人はいますか?それとも、この問題にIEの回避策はありますか?
ところで、このjQueryステートメントはIE8で機能します: $ text.parent()。css( "background-color"、 "#ff0000");, しかし、それはグラデーションの品質がありません。
前もって感謝します、
- アーノルド
コード:
<style type="text/css">
.formRedBackground
{
background: white;
background: -moz-linear-gradient(top, white, #FF0000);
background: -webkit-gradient(linear, left top, left bottom, from(white), to (#FF0000));
filter:progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000')
filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='white', EndColorStr='#FF0000', gradientType='0');
color:#FFFFFF;
}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$Text = $("td .ms-vb2:contains('Red')");
var myelement = $Text.parent();
myelement.addClass('formRedBackground');
});
解決
私の質問に対する答えを見つけました。 jQueryを変更して、TDの親の関数を実行しました。また、TRの最初の2つのTD要素だけが色付けされるように、要件を変更することになりました。
これが他の誰かに役立つ場合のコードは次のとおりです。
<script type="text/javascript">
$(document).ready(function(){
$Text = $("td .ms-vb2:contains('Beige')");
$Text.parent().each(function() { $("td:lt(2)", this).addClass("formBeigeBackground");});
$Text = $("td .ms-vb2:contains('Black')");
$Text.parent().each(function() { $("td:lt(2)", this).addClass("formBlackBackground");});
$Text = $("td .ms-vb2:contains('Lavender')");
$Text.parent().each(function() { $("td:lt(2)", this).addClass("formLavenderBackground");});
$Text = $("td .ms-vb2:contains('Pink')");
$Text.parent().each(function() { $("td:lt(2)", this).addClass("formPinkBackground");});
$Text = $("td .ms-vb2:contains('Red')");
$Text.parent().each(function() { $("td:lt(2)", this).addClass("formRedBackground");});
});
</script>
これは素晴らしいサイトです、
- アーノルド
所属していません sharepoint.stackexchange