1

ページ内のテキストボックスを配置するタスクがあります。これは私のhtmlコードです。このコードは自動的に生成されます。デフォルトでテキストボックスの位置を作成して配置したいと思います。

@model Resume.Models.Resume

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Resume</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Gender)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Gender)
            @Html.ValidationMessageFor(model => model.Gender)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address)
            @Html.ValidationMessageFor(model => model.Address)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Phone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Phone)
            @Html.ValidationMessageFor(model => model.Phone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DateOfBirth)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DateOfBirth)
            @Html.ValidationMessageFor(model => model.DateOfBirth)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Age)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Age)
            @Html.ValidationMessageFor(model => model.Age)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.City)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.City)
            @Html.ValidationMessageFor(model => model.City)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Country)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Country)
            @Html.ValidationMessageFor(model => model.Country)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.HighSchool)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.HighSchool)
            @Html.ValidationMessageFor(model => model.HighSchool)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CollegePer)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CollegePer)
            @Html.ValidationMessageFor(model => model.CollegePer)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Qualification)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Qualification)
            @Html.ValidationMessageFor(model => model.Qualification)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DegreeYearOfPassout)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DegreeYearOfPassout)
            @Html.ValidationMessageFor(model => model.DegreeYearOfPassout)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PreviousCompanyName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PreviousCompanyName)
            @Html.ValidationMessageFor(model => model.PreviousCompanyName)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

これどうやってするの?jqueryプラグインまたはjqueryコードはありますか?

4

5 に答える 5

0

jqueryを使用すると、要素をidで取得し(idを設定する必要があります)、css属性を操作できます。

異なる位置に配置する必要がある場合に備えて、idで言いました。同じクラスのすべてのオブジェクトを移動する必要がある場合は、クラスごとに取得できます(。の#セレクターを変更します)。

jqueryコードは次のとおりです。

$('#ID').css({ 'ATRIBUTE NAME': 'VALUE' });

それでは、例を見てみましょう。

id = myElementの要素の表示を変更したい場合は、次のようにします...

$('#myElement').css({ 'display': 'none' });

適切なドキュメントはここまたはここにあります

于 2013-02-27T13:07:52.877 に答える
0

要素にIDを追加すると、CSSで追加できます。IDを指定することにより

何かのようなもの :

#ID_ELEMENT
{
 attribute : ...;
}
于 2013-02-27T13:13:11.813 に答える
0

javascriptの記述を避けたい場合は、これらの各要素にクラスがあるため、cssでそれらを簡単にターゲットにできます。特定のコードに対して何かを行う必要がある場合は、生成されたマークアップにIDを追加するか、より高度なcssセレクター手法を使用する必要がありますが、コードが生成されてより堅牢になるため、IDをお勧めします。被付与者は要素の順序を指定します。

于 2013-02-27T13:31:50.787 に答える
0

CSSクラスを定義する

div.editor-field input[type=text]
{
 margin: 0 0 0 0; //just a sample position
 padding: 0 0 0 0;
 ....
}

その後、ドロップするたびに

 <div class="editor-field">
            @Html.EditorFor(model => model.CollegePer)

        </div>

自動的に配置されます

于 2013-02-27T14:00:34.223 に答える
0

uがこれを使用している場合@Html.EditorFor(model => model.Age)、ページ上の要素のIDは#ageになります。

<style>
#age {
ur css here 
}
</style>
use this style to arrange for each once .. 
于 2013-02-28T10:33:26.817 に答える