2017-09-21 5 views
-1

not:の条件でJqueryセレクタが機能しません。 画像がなく、div#loccontPckの中にあるdivsを選択します。 その後、border,padding、およびmarginを適用する予定です。jqueryセレクタがnotで動作しない:condition

これはセレクタである:これは結果

[div.pckItem] 
    [div#mapImg.mapImg] 
    [div.pckItem.imgFall_1.imgPckiCar] 

ある

$('#loccontPck div:not(:has(img)').each(function() { oiDivArr.push($(this)); }); 

正しい結果は次のようになります

[div.pckItem] 
    [div.pckItem] 
    [div.pckItem] 

これは、HTMLである:

<div class="pck" id="loccontPck"> 

    <!-- map --><div class="pckItem" style="margin-top: 5.94444px;"><h2 style="margin-top: 0.775362px;"> Διεύθυνση </h2> 
    <p> Δρόμος 5,3086,Kiti,Larnaka,Cyprus </p> 
    <div id="mapImg" class="mapImg" style="margin-top: 5.94444px;"> 
    <img id="trustMap" src="https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/trustMap.PNG" sizes="(max-width: 561px) 100vw, 50vw" srcset="https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/trustMap.PNG 200w, 
      https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/trustMap.PNG 400w, 
      https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/trustMap.PNG 600w" style="border-top: 0px solid white; border-bottom: 3.56667px solid white; padding-top: 3.56667px; padding-bottom: 0px; margin-top: 3.56667px; height: 392.192px;"> 
    </div><a class="menulink map" href="https://typejoy.biz/dev/personex4/gr/certifoff2map">Δείτε διαδραστικό μεγάλο χάρτη</a> 

    </div><!-- map --> 



    <!-- contacts --><div class="pckItem" style="margin-top: 5.94444px;"><h2 style="margin-top: 0.775362px;"> Επαφές </h2> 
    <p> TEL: +357 1234 5647 </p> 
    <p> Ταχυδρομείο: 
    [email protected] 
    [email protected] 
    </p> 

    <a class="menulink contact" href="https://typejoy.biz/dev/personex4/gr/certifoff2contact">Χρησιμοποιήστε τη φόρμα επικοινωνίας</a> 

    <h2 style="margin-top: 0.775362px;"> Ωρες εργασίας </h2> 
    <p> 24ωρη εξυπηρέτηση, 7 ημέρες την εβδομάδα </p> 

    <h2 style="margin-top: 0.775362px;"> Γλώσσες </h2> 
    <p> Αγγλικά, Ελληνικά, Ρωσικά </p> 

    <p></p><div class="froww" style="margin-top: 5.94444px;">​ 
    <!-- C:\Bitnami\wampstack-7.0.22-1\apache2\htdocs\type70823\public\js\ViewFncJs\social.js --> 
    <a class="facebookBtnRnd bfBtnRnd fisoc" href="social-media-profile-url" id="fbShare"></a><p class="socMsg">Share on facebook</p> 
    <a class="twitterBtnRnd bfBtnRnd fisoc" href="social-media-profile-url" id="twitterShare"></a><p class="socMsg">Share on Twitter</p> 
    <a class="googleplusBtnRnd bfBtnRnd fisoc" href="social-media-profile-url" id="gplusShare"></a><p class="socMsg">Share on google+</p> 
    <a class="vkShareBtnRnd bfBtnRnd fisoc" href="social-media-profile-url" id="vkShare"></a><p class="socMsg">Share on VKontact</p> 
    <a class="linkedinShareBtnRnd bfBtnRnd fisoc" href="social-media-profile-url" id="linkedinShare"></a><p class="socMsg">Share on Linkedin</p> 
    <!-- .socMsg { display : none} a.bfBtnRnd:hover + .socMsg {display:block;} --> 

    </div><p></p> 

    </div><!-- contacts --> 




    <!-- fallback photo for streching, on resizing is only 50px height --><div class="pckItem imgFall_1 imgPckiCar" style="margin-top: 5.94444px;"><img id="pexels-photo-193021" src="https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/pexels-photo-193021_1240.jpg" sizes="(max-width: 561px) 100vw, 50vw" srcset="https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/pexels-photo-193021_300.jpg 200w, 
      https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/pexels-photo-193021_560.jpg 300w, 
      https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/pexels-photo-193021_800.jpg 400w, 
      https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/pexels-photo-193021_1040.jpg 550w, 
      https://typejoy.biz/exm/about/about170821b/public/img/HotColImgBundleIMG/red/pexels-photo-193021_1240.jpg 700w"> 
    </div><!-- fallback photo for streching, on resizing is only 50px height --> 



</div> <!-- div class="pck" id="loccontPck" --> 

答えて

1
$('#loccontPck div').not(':has(img)').each(function() { oiDivArr.push($(this)); }); 
-1

私は:not条件の閉じ括弧がありませんでした:)

$('#loccontPck div:not(:has(img))).each(function() { oiDivArr.push($(this)); } 
+0

我々は_...がその問題によって引き起こされたように、我々は閉鎖する/投票を閉じて、タイプミスのための答えを投稿しないでくださいもはや再現することができないか、単純な誤植である。 – LGSon

関連する問題